You are hereCreate a SharePoint Content Type programmatically / Reply to comment
Reply to comment
When I try to update my
Submitted by Steve (not verified) on Tue, 08/07/2008 - 9:12am.
When I try to update my content type (following this guide almost exactly) I get "A content type which does not belong to a collection cannot be updated" as a fatal error. This is thrown on SPContentType.Update(bool, bool) and through reflector I'm pretty sure this code block is throwing it:
if ((this.Collection != null) && (this.Collection[this.Id] == null)){ throw new SPException(SPResource.GetString("CannotUpdateContentType", new object[0]));}
the second condition of the if is the confusing/important part -- why would the SPContentTypeCollection of the web not being updated to include my new ContentType?
I'm declaring the content type like this: SPContentType OSUMC_Item = new SPContentType(web.AvailableContentTypes["Item"], web.ContentTypes, "MyCType");