Sunday, June 14, 2009

Web Application scoped Feature get auto activated

Scenario:
I had a timer job running with scope of Web Application and I faced an issue where I wanted to use it for only one Web Application , but when ever some one create a new Web Application , this feature was getting activated automatically.


I suspected of some auto activate property because I used AutoActivateInCentralAdmin before, and that's what it was. Feature definition support a property ActivateOnDefault , unfortunately its default value is TRUE. I will say big mistake from Microsoft.

As per my fellow friend Sahil this property has no effect on feature scoped at Web and Site level , it only works for Farm and Web Application level.

Solution:
Setting the ActivateOnDefault to FALSE solved the issue.

Code:

<?xml version="1.0" encoding="utf-8"?>  
<Feature Id="GUID" Title="Web App Timer" Scope="WebApplication" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" ActivateOnDefault="False"> xmlns="http://schemas.microsoft.com/sharepoint/"
<ElementManifests>
<ElementManifest Location="elements.xml" />
</ElementManifests>
</Feature>
Follow me on Twitter

0 comments: