I've created a custom list with one content type inherited from 'Schedule' (no additional fields). Now I need to add one more content type to the instance of that list in the feature activated event (this content type is also inherited from 'Schedule' and has some additional fields including several taxonomy fields).
the following piece of code: myCustomList.ContentTypes.Add(myCustomContentType);
generates the following error: A duplicate field name "{78190EDB-029C-42d3-A22A-498FE43D9EC0}" was found.
Piece of stack trace:
[SPException: A duplicate field name "78190edb-029c-42d3-a22a-498fe43d9ec0" was found.]
Microsoft.SharePoint.SPFieldLinkCollection.Add(SPFieldLink fieldLink) +1445
Microsoft.SharePoint.SPContentType.UpdateFieldsCollection(Dictionary`2 cachedFields, Guid addedField) +521
Microsoft.SharePoint.SPContentType.ProvisionFieldOnList(SPField field, Boolean bRecurAllowed) +2355
Microsoft.SharePoint.SPContentType.ProvisionFieldsOnList() +634
Microsoft.SharePoint.SPContentType.DeriveContentType(SPContentTypeCollection cts, SPContentType& ctNew) +671
Microsoft.SharePoint.SPContentTypeCollection.AddContentTypeToList(SPContentType contentType) +2319
Microsoft.SharePoint.SPContentTypeCollection.AddContentType(SPContentType contentType, Boolean updateResourceFileProperty, Boolean checkName, Boolean setNextChildByte) +242
Microsoft.SharePoint.SPContentTypeCollection.Add(SPContentType contentType) +24
Microsoft.SharePoint.ApplicationPages.AddContentTypeToListPage.Update(Object o, EventArgs e) +835
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +103
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3103
The 'GUID' is a GUID of a taxonomy hidden text field. Here is it:
<Field ID="{78190EDB-029C-42d3-A22A-498FE43D9EC0}"
Name="MyTaxonomyFieldNameTaxHTField0"
StaticName="MyTaxonomyFieldNameTaxHTField0"
DisplayName="MyTaxonomyFieldNameTaxHTField0"
Group="MyGroupName"
Type="Note"
ShowInViewForms="FALSE"
CanToggleHidden="TRUE"
Hidden="TRUE"/>
I tried recreating the whole web application, changing the GUID of the field...the same thing occurs with any taxonomy hidden text field included in content type (and it doesn't matter if I'm doing it programmatically or through the web. All taxonomy fields itself are activated properly.