Wednesday, May 1, 2013

C# code to force the debugger to launch

There are times where you just can’t manually attach the Visual Studio debugger to your code. Like when you’re trying to debug Sharepoint feature events (FeatureActivated, FeatureDeactivating, etc.) when Visual Studio is deploying your SharePoint project.

For those situations you can use this line of code to attach Visual Studio to your process.

System.Diagnostics.Debugger.Launch();

image

image

Just make sure to remove it before you ship your software.