Feature activation in site definition (onet.xml) throws an error while searching for a list - "Value does not fall within the expected range"
Hi, I am trying to create a site definition using webtemp*.xml and onet.xml. I am creating all my list instances through onet.xml only. I have a feature which I am using to manipulate a list in this site. I have this feature activated through the <SiteFeatures> element in onet.xml. But when I try to create a site using this definition, everything works fine except the feature activation code. The activation code throws me an error - "Value does not fall within the expected range". On further investigating, I found that this is because the list instances are created only after the Site-scoped features and Web-scoped Features are activated and hence in my feature code when I am trying to fetch a particular list, I encounter this error. Could anyone help me out on this. I want the feature to be activated and code to be executed once the site is created through this definition.
June 1st, 2012 10:57pm

Hi Prateesh, You must ensure the site features and web features element in your onenet.xml like the following code. <Configurations> <Configuration ID="0" Name="MyTest"> <Lists> <!--<List FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Type="101" Title="$Resources:core,shareddocuments_Title;" Url="$Resources:core,shareddocuments_Folder;" QuickLaunchUrl="$Resources:core,shareddocuments_Folder;/Forms/AllItems.aspx" /> <List FeatureId="00BFEA71-6A49-43FA-B535-D15C05500108" Type="108" Title="$Resources:core,discussions_Title;" Url="$Resources:core,lists_Folder;/$Resources:core,discussions_Folder;" QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,discussions_Folder;/AllItems.aspx" EmailAlias="$Resources:core,discussions_EmailAlias;" />--> <List Title="Announcements" Type="10000" Url="Lists/Announcements" /> <List Title="ImageLibrary" Type="109" Url="Lists/ImageLibrary" /> </Lists> <SiteFeatures> <Feature ID="F6924D36-2FA8-4f0b-B16D-06B7250180FA"> <!-- Office SharePoint Server Publishing --> </Feature> </SiteFeatures> <WebFeatures> <!-- Publishing feature --> <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416"> <Properties xmlns="http://schemas.microsoft.com/sharepoint/"> <Property Key="WelcomePageUrl" Value="_layouts/SSPFiles/Pages/default.aspx" /> <Property Key="SimplePublishing" Value="true" /> </Properties> </Feature> <Feature ID="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB"> <!-- Office SharePoint Server Publishing --> </Feature> </WebFeatures> Thanks, Jack
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2012 11:14pm

Hi Jack, Thank you for the response. I have mentioned everything in my onet.xml as mentioned by you. I just did a research on this and found that the reason for the error being thrown is the order in which elements are provisioned through the definition in onet. The order in which elements are provisioned is as follows - global onet.xmlSPSite scoped features defined in onet.xml, in the order they are defined in the file.SPSite scoped stapled features, in quasi random orderSPWeb scoped features defined in onet.xml, in the order they are defined in the file.SPWeb scoped stapled features, in quasi random orderList instances defined in onet.xmlModules defined in onet.xml Reference : http://blogs.msdn.com/b/mcsnoiwb/archive/2008/05/28/site-provisioning-order.aspx And since lists are created only after the Site and Web scoped features are provisioned, my feature code does not get the list it is searching for and hence throws the exception. A work around to this solution that I have found out is - First create a feature which will provision all your lists and through list instances. Then activate the feature that is looking for the list (the feature which is throwing the error.) I have tried this and it is working fine. Another suggested work around that was found is creating the site definition using the SPWebProvisioningProvider class. Please refer the link below - http://blogs.technet.com/b/apurdon/archive/2008/02/05/the-mystery-that-is-spwebprovisioningprovider.aspx But since it didn't match my requirements, I had to go with the first approach. Anyways thank you very much for your response. Prateesh Nair (MCTS) | Orion India Systems
June 6th, 2012 12:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics