If you are getting the SPException “The collection cannot be modified.” when calling SPContentType.Update() then ensure that the content type you are updating was not retrieved from the SPWeb.AvailableContentTypes collection. Content types retrieved from this collection (as oppose to SPWeb.ContentTypes) are read-only.
The AvailableContentTypes collection gives you all content types available at the web, i.e. including those content types defined at the parent site collection. If you debug and inspect this collection however, you will see that it has a non-public property called ReadOnly and its value is true. Content types retrieved from this collection also have a non-public property Collection.ReadOnly – which is also true.
If you need to update a content type, retrieve it from the SPWeb.ContentTypes collection instead.
Thanks! You just saved me from a debugging nightmare; I was trying to figure out which of my (many) child content types was causing the problem, and why I was getting an SPException instead of one of the error types documented on MSDN: http://msdn.microsoft.com/en-us/library/ms475889.aspx
Thanks!! really helped me!!!
Saved a lot of time & frustration! Thanks a lot.
Thanks!!! Saved me from a debugging headache!!
Thank you!! You saved a sharepoint newbie!!!
Pingback: Solved collection cannot be modified | Cao Quoc Hung
Thanks, this saved me a lot of time!