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="http://schemas.microsoft.com/sharepoint/">
        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="http://schemas.microsoft.com/sharepoint/">
            <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);

1 Answer 1


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.

  • 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, 2012 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, 2012 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, 2012 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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