Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Sharepoint 2007
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 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.
Posted 1-Jun-12 19:28pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi all,
I just got the solution for this.
I 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. SharePoint provisions in the following order:
1)global onet.xml
2)SPSite scoped features defined in onet.xml, in the order they are defined in the file.
3)SPSite scoped stapled features, in quasi random order
4)SPWeb scoped features defined in onet.xml, in the order they are defined in the file.
5)SPWeb scoped stapled features, in quasi random order
6)List instances defined in onet.xml
7)Modules 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[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 6 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100