我想在功能停用时以编程方式删除内容类型。我已经编写了执行删除的代码:
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.此内容类型没有在任何地方使用,我仍然无法删除它。
有什么方法可以处理这个错误吗?
谢谢,Priya
发布于 2013-11-15 01:30:32
确保删除所有引用,并将其从所有回收站中移除。
例如,如果列表引用了某个内容类型,则它将被移至回收站,而sharePoint仍会看到该引用。从所有回收站(最终用户和网站集)中删除,然后重试。
https://stackoverflow.com/questions/19977806
复制相似问题