Hi,
I got a question regarding content types and their IDs and how to use them with the object model.
First of all, I defined some site columns, a content type using these columns and a list definition using this content type via CAML. Each of the three components is realized as a feature. Another feature creates a list instance of this list definition.
So when I try to add a new item to the list using the my content type I use the following code.
SPListItem listItem = list.Items.Add();
SPContentType type = list.ContentTypes[new ContentTypeId("0x010044fb4458c2eb4800825910845a35554c")];
listItem["ContentTypeId"] = type.Id;
listItem["Title"] = "Titel";
listItem.Update();
When I execute this piece of code the type object is still null, also I'm sure the content type is attached to the list. Debugging the code and inspecting the list's content types shows me that the content type attached to the list doesn't have the id I defined in the content type definition (CAML). The id within the list instance is different but starts with the one I defined in the content type definition. 0x010044FB4458C2EB4800825910845A35554C0077D683BDD9969F4E920A27C334463321
So is this behavior normal? I expected the content type attached to the list to have the same id as in the definition.
My main goal is avoiding to use the name of the content type to retrieve it from the list's content types, but to use the unique id.
bye Flo