Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook

You're reading from   Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook Develop, debug, and deploy business solutions for SharePoint applications using Visual Studio 2010 with this book and ebook.

Arrow left icon
Product type Paperback
Published in Sep 2011
Publisher Packt
ISBN-13 9781849684583
Length 296 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Balaji Kithiganahalli Balaji Kithiganahalli
Author Profile Icon Balaji Kithiganahalli
Balaji Kithiganahalli
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

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 FREE CHAPTER 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 a Feature Receiver


Debugging a Feature Receiver is a different process. It is not like debugging the List Item Event Receivers. As described in the previous recipe, Visual Studio does lots of work behind the scenes and so we are unable to hit the break points.

Apart from that, debugging Feature Receivers are dependent on events that we are trying to debug. In this recipe, we will follow through the process of debugging FeatureActivated and FeatureDeactivating events.

Getting ready

You should have successfully completed the Creating 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. In the solution explorer, select the project and press F4 to bring open the project properties window.

  3. Set the Active Deployment Configuration to No Activation as shown here:

  4. Put break points on both FeatureActivated and Fea ture Deactivating methods and run the project.

  5. This will bring up the site in the default browser. Navigate to Site Actions | Site Settings | Site Actions | Manage site features. This should bring up the page as shown in the following screenshot and you should be able to see your Feature installed, but not activated.

  6. Clicking the Activate button should invoke the debugger now.

  7. Similarly, clicking the Deactivate button should invoke the debugger to hit the break point on the FeatureDeactivating method.

How it works...

By default Visual Studio sets up for Activation of the features. This makes sense as all the different SharePoint projects make use of Features and for test purposes it is very necessary to activate it and execute the solution. So every time a developer creates a SharePoint project, they do not need to remember to set this flag.

This does create a problem for Feature Receivers though. Hence we set the flag to No Activation and there by Visual Studio just installs the solution without activating it.

There's more...

That's right, now we know how to debug Feature Receivers events like Feature Activated and Feature Deactivating. Is there a similar flag that we can set in Visual Studio to Debug Feature Installed and Feature Uninstalled? No, there are no flags that you can set to make debugger stop on the break points on Feature Installed and the Feature Uninstalling methods.

See also

  • Creating a Feature Receiver recipe

  • Debugging Feature Installed Events 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 $19.99/month. Cancel anytime
Banner background image