My blog has moved!

Visit http://blog.adamroderick.com/ and update your bookmarks.

Friday, February 13, 2009

Easily Debug Feature Event Receivers in SharePoint

One of the painful points of SharePoint development is debugging Feature Event Receivers. If you run the feature activation/deactivation from the command line, you can’t attach to the process fast enough. If you run the feature activation from the web, you have to attach to the w3p .exe process, go through multiple screens, and tie up the process while debugging.

A better option is to use the project settings of the project your feature receiver is in. Choose the Debug tab, then in Start external program, put in the path to STSADM.exe (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe. In the command line arguments, put in the arguments for the command you want to run. If it is feature activation, the arguments are –o ActivateFeature –url http:// -filename \feature.xml.

To run, right-click on your project, choose Debug > Start New Instance. The project will build, the feature will begin activation, and Visual Studio will automatically attach to the correct process, stopping at any breakpoints you have set in your Feature Receiver.

Labels:

1 Comments:

Anonymous Anonymous said...

Thanks Adam, It just worked fine

April 24, 2009 at 3:09 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home