网站内容类型使用 - 而删除内容类型错误

如果你得到 “网站使用中的内容类型” 删去的内容类型的错误,而.

更改为列表/库的默认内容类型, 它使用的内容类型.

然后尝试删除该内容类型.

2 网站内容的意见类型使用 - 而删除内容类型错误

  • KKelaiya

    如何找到在此内容类型的库使用?

  • 请参考我的论坛讨论 :
    http://www.mstechblogs.com/Forums/viewtopic.php?f=8&p=12&sid=cee7f065bed1fc88d9759c66b373d4dd#p12

    您可以使用对象模型来寻找 :

    使用系统;
    使用System.Collections.Generic;
    使用Microsoft.SharePoint程序;

    命名空间试验
    {
    类ConsoleApp
    {
    静态无效的主要(串[] 参数)
    {
    使用 (=新的SPSite的SPSite siteCollection(“銈://本地主机”))
    {
    使用 (SPWeb网站= siteCollection.OpenWeb())
    {
    // 获取过时的内容类型.
    SPContentType过时= webSite.ContentTypes[“测试”];

    如果 (过时的 !=空) // 我们有一个内容类型.
    {
    IList的 使用= SPContentTypeUsage.GetUsages(过时的);
    如果 (usages.Count> 0) // 这是在使用中.
    {
    Console.WriteLine(“内容类型在下列地点使用:”);
    的foreach (SPContentTypeUsage在实践中使用)
    Console.WriteLine(usage.Url);
    }
    其他 // 内容类型是不使用.
    {
    // 删除它.
    Console.WriteLine(“删除的内容类型 {0}…”, obsolete.Name);
    webSite.ContentTypes.Delete(obsolete.Id);
    }
    }
    其他 // 没有内容类型找到.
    {
    Console.WriteLine(“内容类型不存在于这个网站集。”);
    }
    }
    }
    Console.Write(“\n按ENTER键继续…”);
    Console.ReadLine();
    }
    }
    }

    其他选项都将使用SQL查询 (要注意其有点冒险)

    选择 *
    从AllUserData
    哪里 (tp_DirName LIKE'%')
    与 ((tp_ContentType ='文件') 和tp_ListId ='C8723B19 - 0DAB - 4F19 - B195 - 3399D5375752′)

    你就可以通过引用项目内容类型. 删除此项目使用下面的查询中引用.

    删除
    从AllUserData
    哪里 (tp_DirName LIKE'%')
    与 ((tp_ContentType ='文件') 和tp_ListId ='C8723B19 - 0DAB - 4F19 - B195 - 3399D5375752′)

给一个答复

你可以使用 这些HTML标签

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>