问题描述
我有沙盒解决方案,它有 2 个功能(都是 sitecollection 级别的功能)我正在使用相同的用户激活这两个功能.
I have sandbox solution which has 2 features (both are sitecollection level features)I am activating both feature using same USER.
功能 1:通过模块文件将 .stp 文件上传到 _catalogs/lt 文件夹
feature 1 : that uploads .stp files to _catalogs/lt folder via module file
功能 2(取决于功能 1):它将通过 .GetCustomListTemplates(spweb) 方法从 _catalogs/lt 获取所有 .stp 文件,但没有文件进入这是我的代码
feature 2 (is dependent on feature 1) : it will get all .stp file via .GetCustomListTemplates(spweb) method from _catalogs/lt, but there are no files coming in here is my code
using (SPSite mySite = properties.Feature.Parent as SPSite)
{
using (SPWeb spWeb = mySite.OpenWeb())
{
spWeb.AllowUnsafeUpdates = true;
SPListTemplateCollection listTemplates = mySite.GetCustomListTemplates(spWeb);
}
}
listTemplates 没有 .stp 文件.它出来的是空的.
listTemplates has no .stp files.it is coming out empty.
请帮帮我...
推荐答案
如果您使用记录中心作为 SharePoint 2010 中根网站的模板,GetCustomListTemplates() 将始终返回 0(零).
If you use the Record Center as the template for your root website in SharePoint 2010, GetCustomListTemplates() will always return 0 (zero).
有一些奇怪的错误导致这种情况发生.
There is some weird bug that makes this happen.
您可以尝试在 SharePoint PowerShell 中运行以下代码.GetCustomListTemplates($web).Count 的返回值将为零,如果您有从记录中心模板制作的根网站.
Here is code that you can try running in the SharePoint PowerShell. The return value for GetCustomListTemplates($web).Count will be zero if you have the root web made from the Record Center template.
$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
可以在以下网页上找到更多信息:
More information can be found at the following web pages:
- http://social.msdn.microsoft.com/Forums/ar/sharepoint2010general/thread/c5455a27-360a-465c-91d5-f81beeac6789
- http://sharepointrecordsmanagement.com/2011/02/
祝你好运!- 杰森
这篇关于SharePoint 2010,SandBox 解决方案,使用 GetCustomListTemplates 中未提供的功能将 .STP 文件上传到 _catalogs/lt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!