Sharepoint 2010 在功能删除期间删除内容类型
我想在功能停用时以编程方式删除内容类型。我已经编写了执行删除的代码:Sharepoint 2010 在功能删除期间删除内容类型,sharepoint-2010,content-type,feature-receivers,Sharepoint 2010,Content Type,Feature Receivers,我想在功能停用时以编程方式删除内容类型。我已经编写了执行删除的代码: SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPWeb webSite =(SPWeb)properties.Feature.Parent) { webSite.AllowUnsafeUpdates = true; // Get the obsolete conten
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);
}
}
}
});
此内容类型未在任何地方使用,但我无法删除它
有没有办法处理这个错误
谢谢,
Priya确保删除所有引用,并将其从所有回收站中移除
例如,如果列表引用的内容类型被删除,它将被移动到回收站,sharePoint仍会看到引用。从所有回收站(最终用户和网站集)中删除,然后重试。此内容类型是否与您尝试删除它的功能相同?可能以前删除过此内容类型?
The content type is part of an application feature.