Problem with WebControl Solution feature receiver code

Sep 11, 2008 at 8:14 PM
The generate feature receiver code generates code that can prevent the feature from being activated.

Specifically, the following code will fail (and has failed for me) when activating a feature if your Web.Config file already has a configuration/system.web/pages/controls section:

site.WebApplication.WebConfigModifications.Add(controlsSection);
site.WebApplication.WebConfigModifications.Add(addElement);
site.WebApplication.Update();
site.WebApplication.WebService.ApplyWebConfigModifications();

The generated code should first check to see if that section exists before trying to add it.

In my case, I had this section because I activated a feature for the 3.5 framework, which added the configuration/system.web/pages/controls section.