in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Sharepoint Space

It is all about Sharepoint

Lesson learned when create list instance in Sharepoint solution

It took me plenty of time to figure out how to create a sharepoint list/document library instance and delpoy to the Sharepoint in a solution. I experienced some weird error message and it is really frustrating untill everything works at the last!

1. Project structure and features
Make sure completely understand how feature and solution works in Sharepoint. Understand how to create feature head file and feature detail file. Not necessary to memorize all the element but you must know where and how to find it at msdn. It is also very important to build your file structure properly first, otherwise it will easy comfuse youself later when the project grows. A good practice is create a Sharepoint list using VseWSS and study the structure. Key files to study are: Manifest.xml, setup.bat, feature.xml, instance.xml. You need also has the knowledge to create ddf file for your own projects. You could also implement MSBuild for your project in the future...

2. Make sure follow the rules
Exception from HRESULT: 0x81070201
I got this error message once and really took me long time to fix the problem. Finally, I found the folder name has to be exactly the same you defined in your element.xml. Sounds weird? Ask MS but to make it work, you have to rename the folder name and your ddf file as well.

3. Only Content controls are allowed directly in a content page that contains Content controls.
This error message is also misleading. If you got this message, simply remove the commented line in the AllItems.aspx and the rest .aspx pages. (Who says the commented line does not impact your project??? )

4. Two features for 1 list
When create list or document library, Sharepoint actually wants you to create 2 features for it.
First one is just instance of the list or document library. You might need:
feature.xml and instance.xml
the second actually is the schema and default aspx pages.
For list, this feature by default should contain: AllItems.aspx, DispForm.aspx, EditForm.aspx, NewForm.asxp, schema.xml, elementManifest.xml
For docLib, this feature by default should contains: AllItems.aspx, combine.aspx, dispform.aspx, editdlg.htm, editform.aspx, filedlg.htm, repair.aspx, schema.xml, upload.aspx, webfldr.aspx
The second feature acutally defines the default behavior of the list or docLib.

5. Event receiver
Event receiver defines the event and action during or after certain activity. For example, after the feature activated or after the item added. It is quite useful when you build your installation package and control your list/docLib. This can be defined in your feature.xml. For example:
 <Feature
Title
="XXXYYYZZZ"
Id="282A5A9B-465F-4b4d-BB79-B5F6DD2B5A40"
Description
="Your description"
Version
="1.0.0.0"
Scope
="Web"
Hidden="FALSE"
DefaultResourceFile
="core"
ReceiverAssembly
="MyTest.Sharepoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1cf6b1266b9b906" ReceiverClass="MyTest.Sharepoint.MyTestFeatureEventReceiver"
xmlns
="http://schemas.microsoft.com/sharepoint/">

-   <ElementManifests>
       <ElementManifest Location="instance.xml" />
 </ElementManifests>
</Feature>
 

Comments

 

john even said:

thanks for lesson 3 learned. hassled me for a couple of hours.

November 13, 2007 7:46 AM
 

govind said:

hey, thanks for your valuable suggestions , i managed to solve my problem quickly....

April 25, 2008 5:06 AM
 

how to find list id for sharepoint list said:

Pingback from  how to find list id for sharepoint list

May 13, 2008 4:36 PM
 

Dany said:

nice post.......thanks a lot.........

got some of my issues solved..

May 27, 2008 1:28 PM
 

Aleksey said:

Could you please send me the solution to alexey.sergeevi4@rambler.ru? My solution installs without problems, features are activating, but no instance is showing :(.

June 17, 2008 10:35 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts