<native> error when using Custom Content Type in Custom List Template

I found an odd issue using the Visual Studio 2010 Tools the other day.  Only just gotten around to writing about this, as it’s been a hectic few weeks.  Well it’s not odd, but it caused me a few head scratching moments until I realised what was going on.  Here’s the scenario:

  • I create a custom content type and add it to a feature.
  • I create a list template based upon the custom content type using the VS2010 tools  and add it to a feature.
  • I create a list instance of the content type using the VS2010 tools and add it to a feature.
  • When I run the feature to create the list instance I get one of those horrible <native> errors which refers to an incomprehensible or irrelevant error.
    However when I create a list instance through the UI from my List Template everything works fine…

It transpire it’s because when you do the steps this way there is something missing from the List Instance CAML. The feature ID. VS2010 doesn’t appear to figure out what Feature the List Template resides in when it creates the List Instance CAML.

So here’s how to avoid the error:

  • Create a custom content type and add it to a feature.
  • Create a list template based upon the custom content type using the VS2010 tools and add it to a feature.
  • Deploy the List Template
  • Create a list instance of the content type using the VS2010 tools referencing the deployed List Template and add it to a feature.
    Now everything works fine, because the List Instance CAML has the Feature Id in it.

Problem solved. Hope this helps!

Cheers

Dave Mc

Advertisements

About davemcmahon81
Software Developer & Architect, User Group Leader, Speaker, Writer, Blogger, Occasional Guitarist, Man-made Global Warming Sceptic, Climate Change Believer, General Optimist but most of all proud Husband and Dad ...

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: