Sharepoint 2010 SharePoint 2010,沙盒解决方案,使用GetCustomListTemplates中未提供的功能将.STP文件上载到_catalogs/lt

Sharepoint 2010 SharePoint 2010,沙盒解决方案,使用GetCustomListTemplates中未提供的功能将.STP文件上载到_catalogs/lt,sharepoint-2010,Sharepoint 2010,我有一个沙盒解决方案,它有两个功能(都是站点集合级别的功能) 我正在使用同一用户激活这两个功能 功能1:通过模块文件将.stp文件上载到\u catalogs/lt文件夹 功能2(依赖于功能1):它将通过.GetCustomListTemplates(spweb)方法从_catalogs/lt获取所有.stp文件,但没有文件进入 这是我的密码 using (SPSite mySite = properties.Feature.Parent as SPSite) {

我有一个沙盒解决方案,它有两个功能(都是站点集合级别的功能) 我正在使用同一用户激活这两个功能

功能1:通过模块文件将.stp文件上载到\u catalogs/lt文件夹

功能2(依赖于功能1):它将通过.GetCustomListTemplates(spweb)方法从_catalogs/lt获取所有.stp文件,但没有文件进入 这是我的密码

 using (SPSite mySite = properties.Feature.Parent as SPSite)
            {
                using (SPWeb spWeb = mySite.OpenWeb())
                {
                    spWeb.AllowUnsafeUpdates = true;
                    SPListTemplateCollection listTemplates = mySite.GetCustomListTemplates(spWeb);
    }
}
listTemplates没有.stp文件。它是空的


请帮助我…

您的列表模板是否源自“讨论板”之类的默认列表模板?我注意到,当我尝试执行以下操作时,我遇到了与您相同的问题:

  • 将SharePoint 2007“讨论板”列表另存为列表模板
  • 使用此中的方法将模板转换为SharePoint 2010
  • 将模板上载到我的SharePoint 2010网站
  • 我注意到默认的“讨论板”列表模板甚至不是在SharePoint 2010中创建新列表的选项。因此,我转到网站功能,打开“团队协作列表”,只是为了启用默认的“讨论板”列表模板。 完成后,当我创建新列表时,默认的“讨论板”列表模板和自定义的“公告板”模板都出现了。然后我转到我的powershell脚本,注意到GetCustomListTemplates返回了我的自定义模板。我想这意味着C#也应该起作用

    以下是旧SharePoint 2007网站的列表:

    以下是在新的SharePoint 2010网站中启用“讨论板”列表模板的协作功能:

    以下是启用团队协作列表功能后在新SharePoint 2010网站中创建新列表的菜单:


    如您所见,“BulletinBoard”图像与“Discussion Board”图像相同,因此SharePoint可能无法使用“BulletinBoard”模板,因为“Discussion Board”模板尚未安装。

    如果您在SharePoint 2010中将记录中心用作根网站的模板,则GetCustomListTemplates()将始终返回0(零)

    有一个奇怪的错误,使这种情况发生

    以下是您可以尝试在SharePoint PowerShell中运行的代码。如果您使用记录中心模板创建根站点,则GetCustomListTemplates($web)。Count的返回值将为零

    $site = get-spsite("http://localhost")
    $web = $site.RootWeb
    $list = $web.Lists["TestDocLibrary"]
    $list.SaveAsTemplate("MyListTemplate.stp", "MyListTemplate", "My List Template", $false)
    $site.GetCustomListTemplates($web).Count
    
    有关更多信息,请访问以下网页:

    祝你好运! -杰森