Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook

You're reading from  Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook

Product type Book
Published in Sep 2011
Publisher Packt
ISBN-13 9781849684583
Pages 296 pages
Edition 1st Edition
Languages
Author (1):
Balaji Kithiganahalli Balaji Kithiganahalli
Profile icon Balaji Kithiganahalli

Table of Contents (15) Chapters

Microsoft SharePoint 2010 Development with Visual Studio 2010: Expert Cookbook
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. Lists and Event Receivers 2. Workflows 3. Advanced Workflows 4. List Definitions and Content Types 5. Web Parts 6. Web Services and REST 7. Working with Client Object Model Index

Debugging Feature Installed Events


The commands for installing the features are part of the deployment process in Visual Studio. There are no flags or properties that you can set to debug this event in the Feature Receiver. In this recipe, we will guide you through the step-by-step process to accomplish this task.

Getting ready

You should have successfully completed Debugging a Feature Receiver recipe.

How to do it...

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

  2. Retract the solution if it was already deployed to a site.

  3. Uncomment the FeatureInstalled method and press F9 to put in a break point.

  4. Build the solution and package it.

  5. From the command prompt use stsadm to add solution to solution store and deploy it as described in the recipe Deploying the Event Receivers. Follow the steps 8 and 9 in that recipe to deploy the solution.

  6. In the Visual Studio, go to project properties from menu Project | FeatureEventReceiver Properties.

  7. In the Debug tab, set the external program to Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\STSADM.exe.

  8. Enter the command line arguments in the same tab as follows:

      -o installfeature –name FeatureEventReceiver_Feature1 –force
    
    • Your debug tab should be similar to the one shown in the following screenshot:

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

  10. Select the new configuration in the Active Deployment Configuration drop-down.

  11. When you press F5, the debugger stops at the break point on FeatureInstalled method as shown in the following screenshot:

How it works...

In here, we are manually attaching an external process to the Visual Studio debugger. In our case, STSADM.exe is our external program. We did the preliminary work of adding the solution to the solution store and deploying the solution. We bypassed the entire deployment process that Visual Studio uses, so we can debug our Feature Receiver.

By default, Visual Studio provides two configurations: the Default configuration and the No Activation configuration. You cannot edit those configurations. None of these configurations are good for our purpose here. What we needed was a configuration that just deploys the solution without installing it. So we created an empty configuration and resorted to a manual process to debug this solution.

There's more...

Use the same process as used previously to debug the uninstalled event in the Feature Receiver. In step 8, substitute command line arguments as follows:

-o uninstallfeature –filename FeatureEventReceiver_Feature1\Feature.xml

See also

  • Debugging a Feature Receiver recipe

You have been reading a chapter from
Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook
Published in: Sep 2011 Publisher: Packt ISBN-13: 9781849684583
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}