0

我想在功能停用时以编程方式删除内容类型。我已经编写了执行删除的代码:

 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.

此内容类型未在任何地方使用,但我仍无法删除它。

有没有办法处理这个错误?

谢谢,普里亚

4

1 回答 1

0

确保从所有回收站中删除和删除所有引用。

例如,如果列表引用的内容类型被删除,它将被移动到回收站,sharePoint 仍然可以看到引用。从所有回收站(最终用户和网站集)中删除,然后重试。

于 2013-11-14T17:30:32.427 回答