Feature not automatically activating in some site collections

Posted on 2013-02-05
Last Modified: 2013-02-06
I am working on a dev site with no data, it's strictly for design purposes. I have a wsp that contains a feature scoped at "web". The feature contains a list instance. so whenever I deactivate and then try to reactivate, even via code, I run into an error because that list name already exists. I have three site collections, one at the root and two in /sites. My debug env is set to the root url. So to cure this problem, I have added a deletion and creation of each of these three sites in my predeployment so that activation can work. I also am using the default activation settings which pretty much checks for everything and more specifically, activates the features. This only works for the root level site, and the other two sites show the feature fine, but they are not being automatically activated like the root site feature instance was. When i manually activate these two feature instances, it works fine.

My understanding is that when you scope a solution and it's features to "web", which I have done it does the same thing for all webs on all site collections. So theoretically, I should expect to see that the feature was activated at the site features level (not site collection features level) of all site collections. it shows up at the site features level (not site collection features level) ready to be activated when they should be activated already.

Is it that the default deployment has something to do with my dev settings where it only deploys to the root url? So since I use a predeployment command script to delete and recreate all three sites, is it possible that these other two sites are merely picking up the features scoped to "web" upon creation, but the actual activation part of the deployment was never run on them and instead just the root site collection? If so, why? I think it's very important that I understand this thoroughly before I go anywhere near a production env.

Question by:BobHavertyComh
  • 4
  • 3

Accepted Solution

kukdai earned 500 total points
ID: 38855726
I am hoping you are directly deploying the solution from the development tool which has the URL set to your root level site collection.
when you deploy then the solutions or features will be deployed to the URL you have specified in the Dev tool site URL place or target URL.

you can either write another piece of code on web adding or web provisioning events and have your feature activated here.

if i am not mistaken here do you have any code that activated your feature when a site or web is created or provisioned or feature staples with the site definitions.

when you deploy through VISUAL studio if the solution is set to be activate when deployed in properties then it will automatically activate all the features present in the solution to the target URL in your case( your Dev URL), but it doesn't activate it in another Site collection unless you write a code to activate the feature whenever a new web is added or created.

Author Comment

ID: 38855938
I understand and agree totally with what you explained. Thank you. In fact, I even tried to activate from stsadm, and sure enough, it needs a specific url and giving it the root site collection address only activated it there, then giving it the other addresses in separate activation commands activated them there. So it can definitely only activate one at a time, even though it can install to all of them, so it sounds like they did this on purpose.

The problem i have is that the sites are being deleted and re-created during pre-deployment, so it seems like that site creation event code is going to be looking to activate a feature that hasn't been deployed yet.

Assisted Solution

kukdai earned 500 total points
ID: 38856135
you are adding the feature and make it available in web scope but you haven't written to automatically activate the feature.
unless you do it manually either using command or through UI it will never be activated.
for root site the Dev tool does that in behalf of you.
so the best idea is write code in either of events in web level and have the code to activate the feature if not activated.

here is the list of web events you can write::
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.


Author Comment

ID: 38856382
Hi kukdai. Even if I code the web creation events rather than the site creation events, isn't the code going to attempt the activation before the deployment of the feature it is activating and therefore fail? For reasons mentioned above, I need to wipe the site collection out and recreate it during pre-deployment, and even if I did this with a site (web) where only the webs get deleted and recreated, not the site collection, it would still be trying to activate something that hasn't deployed yet and won't until the deployment stage after the creation event has happened.

Author Comment

ID: 38856415
Actually, what I've done is to take activation out of my deployment altogether and added post deployment commands to activate the feature for each site collection url. Worked perfectly, but it means I have to maintain a post deployment list of site collections. Maybe later, I'll attempt a powershell script that walks through all site collections in the farm and activates this feature and see if I can merely copy and paste it into the VS post deployment section of the project properties.

Expert Comment

ID: 38856534
your solutions will remain there doesn't matter you delete or create site collection.
if you delete a site collection it doesn't mean it will delete the feature unless you write a code in site or web deleting event.
in your own solutions of you have a feature then try adding some event receiver in the feature like activated so which will activate another feature the one you want before activating itself.

how does your solutions works.
usually none of the SharePoint solutions works automatically. you are deploying directly from the Dev tool doesn't means that the solutions will automatically run. it is automatically activated becoz the Dev tool runs the command to activate in the site URL mentioned.
your solutions doesn't have anything to activate it automatically.

so first of all.
1. check the Main solutions which creates and deletes the site collection. how does this solutions is run do you have any feature to activate and then it executes. i am hoping you will not have a Dev tool in Prod do deploy the solution you have to write the command manually to add the solutions to prod.

2. if you have any feature in the parent solution then in that solution you can activate the feature after the codes that creates  the sites.

you can use feature stapling as well where features are dependent to each other.
or you can write a command once your site collection code is completed iterate through all site collection and activate the feature.

there are various ways choice is yours how you like

Author Comment

ID: 38859219
Hi kukdai, I enjoy your very thorough knowledge of the subject.

It seems to me that you are saying to not run anything during solution package deployment, using none of VS's auto deployment operations, and instead transfer all necessary deployment operations (retraction/addition/iisreset....) to an on creation event for a site or solution or feature. If so, in the case of a feature creation events, wouldn't I have to write event receiver code for every feature in the solution if the solution grows? Doesn't a VS solution package manage this better where it will act upon all features in the solution and isn't that an advantage to letting it do the deployment operations for you? You mentioned about running commands after all site creation event code has run, but aren't the commands i entered into my post deployment settings in the solution package already doing this for me? seems like it's the same exact thing except I don't have to bother with the command prompt.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now