Wednesday, November 14, 2012

Debugging feature event receiver (related to activation)

When you run project form visual studio, behind the scene visual studio creates and deploy .wsp file and execute all commands for activating the solution. The debugger has not yet attached to the process and hence cannot stop at the break point.

Debugging the feature is different process it is not like debugging item event receiver. Here we go…

We will continue with Create Feature Event Receiver. Below are steps to debug feature events respective to activation events

1. In the solution explorer, select the project and press F4 to open the project properties window.

2. Set the Active Deployment Configuration to No Activation as shown in below fig.

image

3. Now put debugger at FeatureActivated and FeatureDeactivated and run the project.

4. This will bring up the site in browser. Navigate to the site settings and manage site feature you will see below screen.

image

5. Now activate the feature FeatureReceiverLog and it will hit the break point at this time.

In this example we changed the configuration to no activation, in this case visual studio only installs feature and then we manually activate the feature hence it hits the breakpoint.

However what if you want to debug SharePoint feature for FeatureInstalling or FeatureInsatlled event receive it require extra trick, please follow debugging SharePoint feature on FeatureInstalling or FeatureInsatlled event receiver.

No comments:

Post a Comment