Friday 8 February 2013

Debug a Feature Receiver in VS 2010


To debug a feature receiver in Visual Studio 2010:

1. Open the Visual Studio 2010 project that contains your feature.

2. In Solution Explorer, right-click the project node, and then click Properties.

3. On the SharePoint tab, in the Active Deployment Configuration drop-down list, click No Activation.

4. Then attach to the w3wp.exe process that is running your particular SharePoint instance.(However, I  have found that if you need to debug a feature that is activated with stsadm.exe, there is an extra step required.  The reason is that you need to not only attach to the w3wp.exe process but you also need to attach to stsadm.exe as well.).

5. Open the feature receiver class that you want to debug, and then insert a breakpoint. Hit F5 and enjoy!!

6.There is, however a very fast and easy way to start debugging your Feature EventReceiver’s overridden methods, like FeatureActivated() and FeaureDeactivating(): Simply add the following line of code at the point you want to start debugging:

1
System.Diagnostics.Debugger.Launch();



No comments:

Post a Comment