Wednesday, November 14, 2012

Debugging SharePoint feature for FeatureInstalling or FeatureInsatlled event receiver.

In previous post Debugging feature event receiver on Events related to activation we have seen how to debug on FeatureActivating and FeatureDeactivating feature event receiver. Now in this post I will explain how to debug FeatureInstalling or FeatureInsatlled event receiver.

1. Launch Visual Studio as an administrator and open the solution that was created in the previous post.

2. Uncomment the FeatureInstalled method and press F9 to put in a break point. Build the solution and package it.

3. Use below commands to add and deploy the solution with stsadm

stsadm –o addsolution –filename FeatureEventReceiverLog.wsp

stsadm –o deploysolution –name FeatureEventReceiverLog.wsp –local –allowgacdeployment

OR you can use below PowerShell commands

Add-SPSolution FeatureEventReceiverLog.wsp

Install-SPSolution -Identity FeatureEventReceiverLog.wsp -GACDeployment

4. Personally I feel PowerShell commands are easier to use than stsadm commands.

5.In the Visual Studio, go to project properties from menu Project | FeatureEventReceiverLog Properties.

6.Select Debug tab then select start external program and put C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\STSADM.EXE to open stsadm.

7. Enter the command line arguments in the same tab as follows:
-o installfeature –name FeatureEventReceiverLog_Feature1 –force
Your debug tab should be similar to the one shown in the following screenshot:


8. In the window, open the SharePoint tab. create a new Active Deployment Configuration and name it Empty Configuration as shown here and click OK.


9. Select the new configuration in the Active Deployment Configuration drop-down.Now when you press F5, the debugger stops at the break point on FeatureInstalled
Method as shown in the following screenshot.


No comments:

Post a Comment