Archive for February, 2009

Maintain debug information while in release mode

Posted on: (1 Comment

If you have every deployed a website / web application, you would most probably have included some kind of logging mechanism that records any exceptions that occur at runtime. In my case, I like to include a global exception catcher in my apps so that I get notified if a user receives any kind of uncaught exception. The main problem with this approach is that if the application is compiled in release mode you normally would not be able to get an exact handle on the line of code that caused the exception. The trace is still useful but would be much more valuable if the line numbers were included.

Well, this is possible even when your app is running in release mode. Simply update your web.config as follows (note the highlighted compilerOptions tag):

  141 <system.codedom>

  142     <compilers>

  143         <compiler language=”c#;cs;csharp” extension=”.cs” warningLevel=”4” type=”Microsoft.CSharp.CSharpCodeProvider, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089compilerOptions=”/debug:pdbonly>

  144             <providerOption name=”CompilerVersion” value=”v3.5“/>

  145             <providerOption name=”WarnAsError” value=”false“/>

  146         </compiler>

  147         <compiler language=”vb;vbs;visualbasic;vbscript” extension=”.vb” warningLevel=”4” type=”Microsoft.VisualBasic.VBCodeProvider, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089compilerOptions=”/debug:pdbonly>

  148             <providerOption name=”CompilerVersion” value=”v3.5“/>

  149             <providerOption name=”OptionInfer” value=”true“/>

  150             <providerOption name=”WarnAsError” value=”false“/>

  151         </compiler>

  152     </compilers>

  153 </system.codedom>

For more information about emitting debug information follow this link:

Hope this helps.