Feature (de)activation error “The web or site was not found” and Application Pool

I am using Microsoft IW Demo VM (2010-10A) for my experiments related to SharePoint, in all cases when I don’t have time (read: when I’m lazy) to create complete SharePoint Dev environment.

Problem

This particular time I was playing around with site-scoped features and newly created site collection. So here is my workflow:

  1. Create feature with feature receiver

  2. Deploy to Site Collection from Visual Studio using “No Activation” deployment profile

  3. Activate feature from “Site Collection Features” interface in Site Collection Administration

and, in step 3 – BOOM, I receive YSOD from my SharePoint.

2012-07-10-SP80ActYsod

I tried different approach on deployment – so I change deployment profile to “Default”. Site feature is now activated and working. Now, when I try to de-activate it from “Site Collection Features” interface, I again receive YSOD.

Something is, really, not working correctly, so, as usual, I switch to ULS log reader and try all this again. ULS is not giving me really good answer. It simply says “Feature Activation: The web or site was not found.” So, I switch gears and use another resource – Bing Search, searching with this search term that I got as ULS error. Outcome: no relevant result on first two pages of search results.

2012-07-10-SP80UlsError

It seems I got stuck! Luckily, this is not “real” project so I am not in the stage to bang my head against the wall.

I try, again, different approach. Because I have feature receiver that should run on Feature activation, I try to debug project from Visual Studio, set breakpoint inside feature activation event handler and discover that breakpoint is never hit.

Solution

In the end, I open IIS manager to check if everything is working properly – My site is using “SharePoint – 80” Application Pool which is started and working. Everything is fine here… But, WAIT! This is not the AppPool that was originally used for this Web Application. So, when I changed the application pool to default “SharePointContentAppPool”, everything started to work properly: activation, deactivation and debugging. Problem is solved!

2012-07-10-SP80AppPool

2012-07-10-SP80CorrectAppPool

Background

Apparently, during some of my demos (yes, I used this VM for demoing on conferences and during trainings I held recently, as my colleagues and friends already know, and yes, it has more than 100 days of working, and yes again, I’m lazy) I changed AppPool from default “SharePointContentAppPool” to this, newly created “SharePoint – 80”. Afterwards, I used the VM occasionally, creating some web parts, list definitions ,etc., but all of that was Web scoped and didn’t had problems with features. Problems started to appear when I started to work with features scoped to Site Collection.

Lesson learned: After demos, remember to change any custom settings back to default. It can save you some time…