SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a site definition which provisions a subsite based to a webtemplate(wsp) file. This webtemplate file is packed in a feature containing a module.When the feature is activated the wsp file is added to the solution gallery. Another feature, a provisioning handler then creates a subsites based on this template.

My Problem

  1. Just adding to the solution gallery does not activate the solution. Unless the added solution is activated it cannot to used as a template. How can I activate the solution through code?
  2. Alternatively we can add the solution to SPFarm.Solutions and then perform deploysolution. Is it a good idea to proceed this way?
  3. Is there any better approach to this requirement?

Any help would be greatly appreaciated.

share|improve this question

I would deploy wsp and activate it and handle only activation of desired features on specified web/site collection.

Activation of features can be done by website template where you can specify features to be activated.

I'm not saying this is the best approach but we use it on many projects. If there is any better solution I'd be glad to know something new and improve our deployment process.

share|improve this answer
When i use: SPUserSolutionCollection solutionsCollection = currentSite.Solutions; foreach (SPUserSolution solution in currentSite.Solutions) {string name = solution.Name; if (solution.Name.ToLower() == "mysolution.wsp") {mysolutionID = solution.SolutionId;}} I see currentSite.Solutions.count = 0. I tried both SPSite.solution and SPWeb.solution and end up with the same issue. What do you think I'm missing here? – vivek sisodiya Feb 1 '13 at 6:51
I'm not sure but isn't this only user uploaded solutions?… I never tried activating specific solutions, I'd rather go the way activating features. If you have to activate different solutions for different site coll., split them rather into more web apps – luccio Feb 1 '13 at 8:40
If currentSite.Solutions.Count == 0 it may be because your sandbox-solution (WSP) is not provisioned at the root level of your site collection, but at the sub-site level. – Evariste Feb 1 at 8:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.