Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2010 在功能删除期间删除内容类型_Sharepoint 2010_Content Type_Feature Receivers - Fatal编程技术网

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.