NullReferenceException
, this is especially relevant as there is no other way to determine what went wrong.In the past I had to deploy a debug build of the application and set
debug="true"
within the compilation section of web.config, in order to be able to see the line numbers in error logs. But this is not a good idea, as this adversely affects application performance (see this blog from Scott Guthrie for more details and this blog for even more details). So please, always set debug="false"
in production environments. Or, even better, set deployment retail="true"
in your production machine.configBut what do we do if we really want more detailed error information in our logs? There appears to be a an easy way to do this. In the properties of your project, in the Build section, select your Release configuration, click Advanced and make sure that Debug Info is set to pdb-only. This is equivalent to setting this compiler option:
/debug:pdbonly
in the compilerOptions
attribute of the compiler
element in web.config (for more details about this compiler option read this MSDN article and this blog article). This will emit your optimized release assemblies together with corresponding .pdb files containing all the information needed to reference files and line numbers in exception stack traces. You can then deploy the build output into your production environment.This will allow you to log error details like line numbers without significantly affecting the performance of your compiler-optimized release assemblies. Warning: if you do this, then also please make sure that you don't set
customErrors mode="off"
so that you don't expose detailed exceptions to remote users (which is a wise thing to do from security standpoint!)Happy coding!
Nice to read this post which is really good thanks for sharing this information.
ReplyDeleteASP.NET developers | PHP developers
I am working on a web application in visual studio. When I click on the properties page > Build I do not see any release configuration or advance button. Is there a different way to set pdb files in visual studio 2017?
ReplyDeleteNice post, Thanks for sharing Get more update at
ReplyDeleteDot Net Online Training
Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
ReplyDeleteJava Training in Chennai | J2EE Training in Chennai | Advanced Java Training in Chennai | Core Java Training in Chennai | Java Training institute in Chennai
Thanks for sharing such informative guide on .Net technology. This post gives me detailed information about the .net technology. I am working as trainer in leading IT training academy offering Dot Net Training in Chennai
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
ümraniye toshiba klima servisi
ReplyDeletebeykoz alarko carrier klima servisi
üsküdar alarko carrier klima servisi
beykoz daikin klima servisi
üsküdar daikin klima servisi
ataşehir toshiba klima servisi
ataşehir beko klima servisi
ümraniye beko klima servisi
beykoz lg klima servisi