Note that there are some explanatory texts on larger screens.

plurals
  1. POSource file information missing in StackTrace, when PDB loaded from another folder
    primarykey
    data
    text
    <p>I'm trying to get a stack-trace information at runtime.</p> <p>I'm using following code, and this works fine in the default project configuration:</p> <pre><code> StackTrace trace = new System.Diagnostics.StackTrace(true); StackFrame frame = trace.GetFrame(0); int line = frame.GetFileLineNumber(); Console.WriteLine(line); </code></pre> <p>However, the solution I'm trying to build is configured to put binaries and PDBs to separate folders:</p> <pre><code>&lt;PropertyGroup&gt; ... &lt;OutputPath&gt;Binaries\$(Configuration)\bin\&lt;/OutputPath&gt; &lt;IntermediateOutputPath&gt;Binaries\$(Configuration)\obj\$(MSBuildProjectName)\&lt;/IntermediateOutputPath&gt; &lt;PdbFile&gt;Binaries\$(Configuration)\pdb\$(MSBuildProjectName).pdb&lt;/PdbFile&gt; &lt;SkipCopyingSymbolsToOutputDirectory&gt;true&lt;/SkipCopyingSymbolsToOutputDirectory&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "&gt; &lt;PlatformTarget&gt;AnyCPU&lt;/PlatformTarget&gt; &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt; &lt;DebugType&gt;full&lt;/DebugType&gt; &lt;Optimize&gt;false&lt;/Optimize&gt; &lt;DefineConstants&gt;DEBUG;TRACE&lt;/DefineConstants&gt; &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt; &lt;WarningLevel&gt;4&lt;/WarningLevel&gt; &lt;/PropertyGroup&gt; </code></pre> <p>I can see in <code>Modules</code> window in Visual Studio that PDB was loaded. However, the <code>frame</code> variable doesn't contain information about source file (filename, line and column). If I copy .pdb and .exe to the same folder, output is correct again. </p> <p>Therefore, as far as I understand:</p> <ul> <li>PDB is correct (contains necessary information), because it works when I put files to the same folder</li> <li>Visual studio is able to load the PDB, so the search path should also be correct</li> </ul> <p>I have searched the internet (including <a href="http://msdn.microsoft.com/en-us/library/ee416588.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ee416588.aspx</a> and <a href="https://stackoverflow.com/questions/628565/display-lines-number-in-stack-trace-for-net-assembly-in-release-mode">Display lines number in Stack Trace for .NET assembly in Release mode</a>), but all article mostly focus on loading PDBs from correct location (and as far as I'm concerned, that's not the case). What I do not understand is <strong>why</strong> the source-file/line information is not be obtained, although PDB is loaded.</p> <p><strong>So, the question is</strong>: is it possible to get Stack Trace containing information about source-files, when .pdb was loaded from different location? If not, why?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload