SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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'm trying to add content types into a library list, in order to make "Visible on New" option ticked.

Firstly I enabled contenttypes in the library, then I want to do this:

SPFolder rootFolder = list.RootFolder;
IList<SPContentType> ctList = rootFolder.ContentTypeOrder;
rootFolder.UniqueContentTypeOrder = ctList;

But this line IList<SPContentType> ctList = rootFolder.ContentTypeOrder; keeps throwing unexpected error:

Error occurred in deployment step 'Activate Features': 
Unhandled exception was thrown by the sandboxed code wrapper's Execute 
method in the partial trust app domain: An unexpected error has occurred.

I'm not sure if this error is related to the sandbox solution.

Related question: Content Types not visible under New Button

share|improve this question
up vote 4 down vote accepted

It's related to the sandbox, because you cannot use SPFolder.ContentTypeOrder and SPFolder.UniqueContentTypeOrder in sandbox :\

Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Available in Sandboxed Solutions: No


If it's just to order, the code posted as an answer by James in this question might work.

share|improve this answer
Thanks! However I'm not ordering... I just want to enable the CT on New button – wceo Jan 16 '13 at 9:17

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.