首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >功能取消激活时删除内容类型

功能取消激活时删除内容类型
EN

Stack Overflow用户
提问于 2013-11-14 20:34:23
回答 1查看 472关注 0票数 0

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

代码语言:javascript
运行
复制
 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);
                }
            }


        }
     });

但它给了我一个错误:

代码语言:javascript
运行
复制
The content type is part of an application feature.

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

有什么方法可以处理这个错误吗?

谢谢,Priya

EN

回答 1

Stack Overflow用户

发布于 2013-11-15 01:30:32

确保删除所有引用,并将其从所有回收站中移除。

例如,如果列表引用了某个内容类型,则它将被移至回收站,而sharePoint仍会看到该引用。从所有回收站(最终用户和网站集)中删除,然后重试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19977806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档