2016-08-08 3 views
4

.NET 어셈블리를 만들 때 해당 .pdb 파일 경로의 위치가 포함되어있는 것 같습니다. 참조 용 링크 : https://msdn.microsoft.com/en-us/library/ms241613.aspx.NET 어셈블리 내부에서 해당 .pdb를 찾는 방법은 무엇입니까?

어떻게 접근합니까? ILSpy를 사용하여 어셈블리를 살펴 보았지만 찾을 수 없습니다.

+0

당신이 프로그래밍 방식으로 경로를 얻기 위해 또는 도구를 사용 하시겠습니까? – Jehof

답변

1

dumpbin 도구는 개발자 명령 프롬프트에서 사용할 수 있습니다 (예 : 이

dumpbin /HEADERS YourAssembly.exe 

같은 cmd를 라인은 내가 다음 해키 솔루션에 온이

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

유사한 디버그 디렉토리 섹션의 PDB 파일의 경로를 보여줄 것이다.
그것은 나를 위해 작동하지만, 나는 그것의 정확성을 :) 보장 할 수 없습니다

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); 
} 
관련 문제