开发者

Debug symbols in release mode

开发者 https://www.devze.com 2022-12-11 00:08 出处:网络
On an ASP.NET 2.0 website I log details of unhandled exceptions. I would like to log the source filename and line number, but I don\'t get this in the stack trace when an exception occurs. The reason

On an ASP.NET 2.0 website I log details of unhandled exceptions. I would like to log the source filename and line number, but I don't get this in the stack trace when an exception occurs. The reason for this is that I have debug="false" in the web.config compilati开发者_StackOverflow社区on settings (it's a production site), therefore no PDB files are being generated on the server. Is there a way to get ASP.NET to generate the debug symbol files in release mode? I don't want to precompile the site.


OK, I found an answer. You can set debug="false" to get optimisations, and then set compilerOptions="/debug:pdbonly" in the system.codedom compiler settings to get symbols. Here's the relevant web.config excerpts:

<system.web>
  ....
  <compilation debug="false" defaultLanguage="c#">
  ...
  </compilation>
</system.web>
<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
        type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        compilerOptions="/debug:pdbonly">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="WarnAsError" value="false"/>
    </compiler>
    ...
  </compilers>
</system.codedom>


Unless Im missing something the difference between debug & release build are in the optimizations. You should be able to create a normal debug binary with pdb and make sure to enable all the optimization settings in the project settings. Afaik unless theres an exception the pdb file wount be loaded, etc...

0

精彩评论

暂无评论...
验证码 换一张
取 消