Solved

Feature not automatically activating in some site collections

Posted on 2013-02-05
7
650 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

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

Author Comment

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

Assisted Solution

by:kukdai
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::
http://msdn.microsoft.com/en-us/library/ff408183%28v=office.14%29.aspx
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 9

Author Comment

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

Author Comment

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

Expert Comment

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

Author Comment

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

Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 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