Solved

Feature not automatically activating in some site collections

Posted on 2013-02-05
7
595 Views
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.

Thanks.
0
Comment
Question by:BobHavertyComh
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
kukdai earned 500 total points
Comment Utility
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.
0
 
LVL 9

Author Comment

by:BobHavertyComh
Comment Utility
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.
0
 
LVL 9

Assisted Solution

by:kukdai
kukdai earned 500 total points
Comment Utility
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::
http://msdn.microsoft.com/en-us/library/ff408183%28v=office.14%29.aspx
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 9

Author Comment

by:BobHavertyComh
Comment Utility
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.
0
 
LVL 9

Author Comment

by:BobHavertyComh
Comment Utility
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.
0
 
LVL 9

Expert Comment

by:kukdai
Comment Utility
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
0
 
LVL 9

Author Comment

by:BobHavertyComh
Comment Utility
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.

Thanks.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

11 Experts available now in Live!

Get 1:1 Help Now