Pages

Thursday 18 July 2013

Attach debugger Programatically System.Diagnostics.Debugger.Break()

Attach debugger Programatically System.Diagnostics.Debugger.Break()
 
Some SharePoint Developers face difficulty in debugging TimerJobs and also when sometimes there are just too many instances of w3wp.exe are available.
 
System.Diagnostics.Debugger.Break() is a BCL method that causes a program to issue a User Breakpoint when run under the debugger.
Application will ask you to attach debugger at runtime.
Try it out,  

But remember that this statement needs to be removed from code before release build. This is because this statement will be compiled with code even with release build. To make sure you have not put that code accidentally in your release build you can put a preprocessor directive like below:

#if DEBUG
System.Diagnostics.Debugger.Break();
#endif  
 
Thanks Sohel for this
Refrence :  http://ranaictiu-technicalblog.blogspot.in/2009/12/let-your-application-ask-you-to-attach.html

No comments:

Post a Comment