简体   繁体   English

在发布模式下调试符号

[英]Debug symbols in release mode

On an ASP.NET 2.0 website I log details of unhandled exceptions. 在ASP.NET 2.0网站上,我记录了未处理异常的详细信息。 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 compilation settings (it's a production site), therefore no PDB files are being generated on the server. 原因是我在web.config编译设置(它是生产站点)中具有debug =“ false”,因此服务器上没有生成PDB文件。 Is there a way to get ASP.NET to generate the debug symbol files in release mode? 有没有办法让ASP.NET在发布模式下生成调试符号文件? 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. 您可以设置debug =“ false”以获得优化,然后在system.codedom编译器设置中将editorOptions =“ / debug:pdbonly”设置为获取符号。 Here's the relevant web.config excerpts: 以下是相关的web.config摘录:

<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. 您应该能够使用pdb创建普通的调试二进制文件,并确保在项目设置中启用所有优化设置。 Afaik unless theres an exception the pdb file wount be loaded, etc... Afaik除非存在例外,否则将加载pdb文件,等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM