런타임시 스택 추적 정보를 가져 오려고합니다. 별도의 폴더에 바이너리와 PDB의를 넣어, 내가 구축을 위해 노력하고있어 솔루션이 구성되어 그러나다른 폴더에서 PDB를로드 할 때 StackTrace에 소스 파일 정보가 누락되었습니다.
StackTrace trace = new System.Diagnostics.StackTrace(true);
StackFrame frame = trace.GetFrame(0);
int line = frame.GetFileLineNumber();
Console.WriteLine(line);
:
나는 다음과 같은 코드를 사용하고,이 기본 프로젝트 구성에서 잘 작동
<PropertyGroup>
...
<OutputPath>Binaries\$(Configuration)\bin\</OutputPath>
<IntermediateOutputPath>Binaries\$(Configuration)\obj\$(MSBuildProjectName)\</IntermediateOutputPath>
<PdbFile>Binaries\$(Configuration)\pdb\$(MSBuildProjectName).pdb</PdbFile>
<SkipCopyingSymbolsToOutputDirectory>true</SkipCopyingSymbolsToOutputDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
나는 Visual Studio에서 PDB가로드 된 Modules
창에서 확인할 수 있습니다. 그러나 frame
변수에는 소스 파일 (파일 이름, 줄 및 열)에 대한 정보가 없습니다. .pdb와 .exe를 같은 폴더에 복사하면 출력이 다시 올바르게됩니다.
따라서, 지금까지의 내가 이해 :
- PDB가 올바른지 (필요한 정보를 포함), I는
- 비주얼 스튜디오는 PDB를로드 할 수있는 동일한 폴더에 파일을 넣을 때 작동하기 때문에, 그래서 검색 경로는 정확해야 내가 (http://msdn.microsoft.com/en-us/library/ee416588.aspx 및 Display lines number in Stack Trace for .NET assembly in Release mode 포함) 인터넷을 검색했지만 모든 문서는 대부분 정확한 위치에서 PDB의로드에 초점을 (그리고 내가 아는 한, 그이 아니다
케이스). 내가 이해할 수없는 것은 인데 왜인데 PDB가로드되었지만 소스 파일/라인 정보를 얻을 수 없다.
그래서 질문은입니다 : .pdb가 다른 위치에서로드되었을 때 소스 파일에 대한 정보가 들어있는 스택 추적을 얻을 수 있습니까? 그렇지 않다면, 왜?
Visual Studio의 버전과 .Net의 버전은 무엇입니까? – OmegaMan
VS2012 및 타겟팅 .Net 4.0을 사용하고 있습니다. – nevermind