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've a strange problem with activating a feature from C#: I have a list with a event receiver attached, which creates a new sub-site every time a new listitem has been added:

var newWeb = subSites.Add(SPEncode.HtmlEncode(abkuerzung), firmierung, "", cid, "STS#1", false, false);

After creation of the sub-site, which works as expected, i try to activate a custom feature, which is installed on the root web:

newWeb.Features.Add(new Guid("{4017e2cf-5be6-4fb2-9e8a-a176188eb3ca}"), false, SPFeatureDefinitionScope.Site);

The problem is, that the event FeatureActivated does not execute. It will execute, if i activate the feature from the site settings, but not from my code. I checked the Guid, changed the bool which forces the feature to be activated even on errors, but the code inside my event will not be executed.

Any idea will be helpful...

share|improve this question
Are you sure the activated event isn't just firing and failing? Have you set a breakpoint and attach to UserCodeProxy? – Per Jakobsen Sep 5 '12 at 11:51
Use this tool to check if its attached or not – Mathematics Sep 5 '12 at 12:23
@Per I had a breakpoint in the event and the event is not fired. But i digged a little bit deeper - see update. – Thommy Sep 5 '12 at 13:00
Which update??? – Per Jakobsen Sep 5 '12 at 14:01

Your Answer


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

Browse other questions tagged or ask your own question.