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;
rootFolder.Update();
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