Exception when programmatically copying content type
        Posted  
        
            by BeraCim
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by BeraCim
        
        
        
        Published on 2010-04-19T04:16:45Z
        Indexed on 
            2010/04/19
            4:23 UTC
        
        
        Read the original article
        Hit count: 331
        
sharepoint
|sharepoint2007
Hi all:
I'm getting exceptions when copying content type from one web to another:
foreach (SPContentType destinationWebCt in destinationWeb.ContentTypes) 
{ 
    destinationWeb.ContentTypes.Add(existingWebCt); 
    destinationWeb.Update(); 
} 
existingWebCt is the content type from another web e.g. /Site/Web. destinationWeb is the web that I wish to copy the content type to e.g. /Site/DestinationWeb.
I got the SPException that says something like content type can not be added outside of its scope.
Then I decided to replace all "ContentTypes" to "AvailableContentTypes", but then I got the SPException saying this collcetion could not be modified.
So how can I copy a content type to another web?
Thanks.
© Stack Overflow or respective owner