SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

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>
 

Posted 10-30-2007 6:22 PM by mingssn

Comments

john even wrote re: Lesson learned when create list instance in Sharepoint solution
on 11-13-2007 7:46 AM

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

govind wrote re: Lesson learned when create list instance in Sharepoint solution
on 04-25-2008 5:06 AM

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

how to find list id for sharepoint list wrote how to find list id for sharepoint list
on 05-13-2008 4:36 PM

Pingback from  how to find list id for sharepoint list

Dany wrote re: Lesson learned when create list instance in Sharepoint solution
on 05-27-2008 1:28 PM

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

got some of my issues solved..

Aleksey wrote re: Lesson learned when create list instance in Sharepoint solution
on 06-17-2008 10:35 AM

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 :(.

roy joyson wrote re: Lesson learned when create list instance in Sharepoint solution
on 10-24-2008 10:11 AM

nice post..helped

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.