Debugging in Visual Studio


If you don't know what process you have to attach Visual Studio to, or, although Visual Studio seems to be attaching, it does not break the execution on your breakpoint, you can add this line to your code:

 System.Diagnostics.Debugger.Launch();  

When the code execution reaches this line, Visual Studio will be opened in debug mode.

Example:
     public override void FeatureActivated(SPFeatureReceiverProperties properties) {  
       System.Diagnostics.Debugger.Launch();  
       ... more code here ....  
     }  

Note that you have to enable Just-In-time debugging in Visual Studio.

Leave a Reply