SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've an ListDefinition with some references to existing Content Types (provided by CTH) but when the list is created the content types are not added.


<Elements xmlns="">
        DisplayName="My Document Library"
        Description="My Document Library List Definition"


<List xmlns:ows="Microsoft SharePoint" Title="My Document Library" Direction="$Resources:Direction;" Url="ProjectName-MyDocLib" BaseType="1" xmlns="">
            <ContentTypeRef ID="0x0101001239678203837B4FBA21976C8B194FFD02" />
            <ContentTypeRef ID="0x0101001239678203837B4FBA21976C8B194FFD03" />

web feature creation receiver code:

oWeb.Lists.Add(oWeb.Name, "my doc lib description", oWeb.Name, "featureWhereIsListDefID", 10081, "100", SPListTemplate.QuickLaunchOptions.Off);
share|improve this question
up vote 1 down vote accepted

Welcome to the dark side of SharePoint.

To be simple, that does not works (nearly never). When you create a list, duplicate the whole content types and the fields definition within your list.

Yes, you have to copy paste the whole content each time you change an attribute in a field or in a content type.

You can use VS 2012 RC which can help you a bit (a small trick I can explain if needed), but you'll still end in duplicating things.

I just wish someone will write a small extension that will do this work automatically.

share|improve this answer
hahaha! thanks a lot Steve. Dark side indeed, I went for this approach cause I've around 30 CTypes to add, and programmatically takes an eternity (almost 1s foreach oSPList.ContentTypes.Add()). Can you suggest and better approach for this issue? – fallout Jul 6 '12 at 13:15
Unfortunately not. As I said, VS 2012 has new list schema designer, that helps to duplicate the mess. This can help a bit. Another idea, is to create a site, design it using the UI, and export it as a template. A final idea, is to write a Visuaal Studio addin that do the job, or a T4 template, or anything. OF course this assume you are living in the Vault 13, and that you nothing to do of your Saturday. – Steve B Jul 6 '12 at 13:19
hahahaha! Vault 13, u r old school. To bad that I cannot embrace that approach, or others that obligate to duplicate the content types. The idea is to stick into the CTH purpose. However, thanks a lot!!! – fallout Jul 6 '12 at 13:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.