我想在功能停用时以编程方式删除内容类型。我已经编写了执行删除的代码:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPWeb webSite =(SPWeb)properties.Feature.Parent)
{
webSite.AllowUnsafeUpdates = true;
// Get the obsolete content type.
SPContentType obsolete = webSite.ContentTypes["Examples8888 - CT1"];
// We have a content type.
if (obsolete != null)
{
IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(obsolete);
// It is in use.
if (usages.Count <= 0)
{
obsolete.Delete();
// Delete it.
Console.WriteLine("Deleting content type {0}...", obsolete.Name);
webSite.ContentTypes.Delete(obsolete.Id);
}
}
}
});
但这给了我错误:
The content type is part of an application feature.
此内容类型未在任何地方使用,但我仍无法删除它。
有没有办法处理这个错误?
谢谢,普里亚