2016-08-08 5 views
4

Apparemment, lorsqu'un assembly .NET est créé, l'emplacement du chemin de fichier .pdb correspondant est inclus à l'intérieur. Lien pour référence: https://msdn.microsoft.com/en-us/library/ms241613.aspxComment trouver le fichier .pdb correspondant dans l'assemblage .NET?

Comment j'accède à cela? J'ai essayé d'utiliser ILSpy pour regarder à l'intérieur de mon assemblage mais je n'ai pas pu le trouver.

+0

voulez-vous obtenir le chemin ou programatically d'utiliser un outil? – Jehof

Répondre

1

Vous pouvez utiliser l'outil dumpbin à partir d'une invite de commande de développeur, par ex. une ligne cmd comme celui-ci

dumpbin /HEADERS YourAssembly.exe 

montrerait le chemin du fichier PDB dans la section répertoires de débogage similaire à ce

Microsoft (R) COFF/PE Dumper Version 14.00.24213.1 
Copyright (C) Microsoft Corporation. All rights reserved. 


Dump of file YourAssembly.exe 

... 


    Debug Directories 

     Time Type  Size  RVA Pointer 
    -------- ------- -------- -------- -------- 
    570B267F cv   11C 0000264C  84C Format: RSDS, {241A1713-D2EF-4838-8896-BC1C9D118E10}, 1, 
    C:\temp\VS\obj\Debug\YourAssembly.pdb 

... 
1

Je suis venu à la solution hacky suivante.
Il travaille pour moi, mais je ne peux pas garantir l'exactitude :)

public string GetPdbFile(string assemblyPath) 
{ 
    string s = File.ReadAllText(assemblyPath); 

    int pdbIndex = s.IndexOf(".pdb", StringComparison.InvariantCultureIgnoreCase); 
    if (pdbIndex == -1) 
     throw new Exception("PDB information was not found."); 

    int lastTerminatorIndex = s.Substring(0, pdbIndex).LastIndexOf('\0'); 
    return s.Substring(lastTerminatorIndex + 1, pdbIndex - lastTerminatorIndex + 3); 
} 

public string GetPdbFile(Assembly assembly) 
{ 
    return GetPdbFile(assembly.Location); 
}