Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm developing a solution in SharePoint 2010 that deploys a content type. I've now made a change to the content type and want to delete all its old references, remove it, and redeploy.

Unfortunately when I try to delete the content type, either from the UI or code, I get the error:

SPException: The content type "XYZ" is part of an application feature.

I've tried the following steps:

  • deleted all lists referencing the content type
  • emptied the site level and site collection level recycle bin
  • deactivated the feature from the UI and command-line using -force
  • uninstalled the feature from the command-line using -force
  • uninstalled the solution
  • reinstalled the solution and performed all of the above again

Still it will not be moved!

Any ideas?

share|improve this question
    
does the content type have a list definition and list instance associated with it in your feature, or is it only a content type? –  djeeg Apr 13 '11 at 5:35
    
I'm lucky - this problem occurred in my dev environment. I recreated the site collection and the problem went away. –  Alex Angas Apr 13 '11 at 7:15
    
Not a production solution, but glad you were able to clear up your issue! –  Tom Resing Apr 13 '11 at 22:11
    
Abandoning the problem because it happened in dev is not a solution for the original question –  Jorge Carvalho May 6 '13 at 6:45

6 Answers 6

Content Types deployed via a Feature get a flag IsFromFeature in the DB. I don't know of any way to remove this flag by code. When the feature the content type was deployed with is retracted and the content type is not removed upon retraction - you will have the problem as you stated "content type is part of feature[...]".

Besides re-activating the feature you installed the content type with and deleting it then, I can only think of doing this via the DB. Just like you stated - this content type will have no usages (SPContentTypeUsage.GetUsages()), it just has this darn flag in the database.

A writeup about this orphaned content type you can find here: How To Delete an “Orphan” Content Type?, though it is for SP2007.

When running into this problem, I usually try to resolve the problem by re-activating the feature the CT came with.

share|improve this answer
    
Great info, thank you! –  Alex Angas Apr 13 '11 at 23:00
    
We never stop learning ! Thanks a lot for the relevant explanations ! –  Francois Verbeeck Feb 2 '12 at 15:26

Did you verify that your custom content type is not being used as a base type for another content type that is still being used? If so, that type and all references to it must go as well.

Lastly, did you tie a Page Layout to that content type? If so, all pages based on that layout must be deleted before you can delete the layout.

share|improve this answer
1  
It's not a base type, apart from being used in that list which I deleted. It's not being used for page layouts. Good ideas though, thanks! –  Alex Angas Apr 13 '11 at 3:08

Did you already read the "Deleting Content Types" article on MSDN? It guides you on a programmatic approach for detecting usage and deleting content types. http://msdn.microsoft.com/en-us/library/ms453791.aspx

As a last resort you could do a couple of selects (yeah I know you are not supposed to do that, so dont tell anyone if you mess it up ;-)) on the ContentTypeUsage table to find out if you missed a reference or the CT is somehow orphaned. In this case you would set the IsFromFeature to 0 which should allow you to delete the CT using the GUI. DO THIS AT YOUR OWN RISK :-O http://blog.thekid.me.uk/archive/2008/11/03/a-tip-when-looking-at-the-sharepoint-content-db.aspx

Oh and Dave is spot on with contenttypebinding, most people forget to check that :-)

share|improve this answer
    
Yes tried that and got the same error unfortunately. –  Alex Angas Apr 13 '11 at 7:15
    
so you have NO references to it in ContentTypeUsage ? –  Anders Rask Apr 13 '11 at 7:31
    
Nope :( –  Alex Angas Apr 13 '11 at 7:33

I just ran into the same problem with a Content Type deployed declaratively(i.e. using elements.xml) as part of a farm solution. Here are a couple things I noticed.

  • I only encountered the problem when the SPContentType's FeatureId property was set to a value other than the empty GUID(i.e. 00000000-0000-0000-0000-000000000000) However, when the FeatureId property was set to the empty GUID, I did not encounter the problem; when the content type's associated feature was disabled/deactivated then the content type would be deleted (note: I still received the error if I tried to delete the content type while the feature was enabled)
  • The only time that the FeatureId was set to a value other than the empty GUID was when I set Inherits="FALSE" in the ContentType element. I didn't test the scenario when you don't specify the Inherits attribute, but according to the documentation, it may exhibit different behavior.

So, setting Inherits="TRUE" in the ContentType element may help you avoid this issue. I was unable to find any way to solve the problem using the api once the FeatureId is set to a value. Perhaps modifying the database, as suggested in a different answer, may fix it.

EDIT: I did test the scenario where the Inherits property is not specified and it seems to result in the same behavior as setting Inherits="FALSE".

share|improve this answer

You should be able to delete any feature content type (XY) following these steps:

  1. Delete any content type that derives from XY (you can find it using powershell or in SQL in table ContentTypes)
  2. Delete any item with content type XY
  3. Remove content type XY from all lists or delete the lists (these are ContentTypeUsages)
  4. Empty ALL recycle bins (there are 3)
  5. Deactivate feature with content type XY FROM UI (definitely NOT with the -FORCE parameter) If you don´t have the feature anymore, create dummy feature, with fake CT - put the right content type ID and Name, other attributes doesn't metter, even the FieldRefs node doesn't matter.
  6. Check the site content types, if XY remains there, some of the steps 1,2,3 or 4 were not completed successfully.
share|improve this answer

Best way to delete content types

  1. Save the site as template, save it to a physical location
  2. Open Visual Studio, create new project under sharepoint- Import SharePoint Solution Package
  3. Naming convention for solution to be very small like ST
  4. Save the project in folder with small file path as C:\HB
  5. In the solution explorer in the project under content types, remove the unwanted contentTypes
  6. Save the Project, Build & Deploy either from VS or Powershell
  7. The content types are deleted without removing the feature :)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.