通过SharePoint 2007中的事件接收器找不到SPListTemplate
我有一个自定义的网站模板,它通过事件接收器激活一个功能,接收器所做的唯一事情就是激活一些其他功能,所有这些功能都在同一个接收器中 我激活的第一个功能是一个名为“审计”的列表模板。 在我激活的第三个特性中,我尝试通过对象模型使用该模板,但是找不到它,因此它会引发异常 我试图用通过SharePoint 2007中的事件接收器找不到SPListTemplate,sharepoint,sharepoint-2007,Sharepoint,Sharepoint 2007,我有一个自定义的网站模板,它通过事件接收器激活一个功能,接收器所做的唯一事情就是激活一些其他功能,所有这些功能都在同一个接收器中 我激活的第一个功能是一个名为“审计”的列表模板。 在我激活的第三个特性中,我尝试通过对象模型使用该模板,但是找不到它,因此它会引发异常 我试图用web.update()更新网站,但也没用 当通过网站模板激活时,代码不起作用,这意味着,如果我从已经创建的网站激活我的功能,它可以正常工作 在创建站点时,是否有方法访问ListTemplate 提前谢谢 编辑:这是主要功能
web.update()
更新网站,但也没用
当通过网站模板激活时,代码不起作用,这意味着,如果我从已经创建的网站激活我的功能,它可以正常工作
在创建站点时,是否有方法访问ListTemplate
提前谢谢
编辑:这是主要功能
/// <summary>
/// Evento disparado al activar la feature
/// </summary>
/// <param name="properties"></param>
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//Obteniendo el sitio (web) en donde fue activada la feature
SPWeb web = (SPWeb)properties.Feature.Parent;
//Guid a utilizar para instalar las features
Guid g;
//GUID de Feature de list template de auditorías
g = new Guid("{3b91e461-e8c9-49dd-857a-671eb031017c}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature Catalogos
g = new Guid("{d102dd61-0aaf-4a18-8bcc-2260e78cc87c}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature Content type de auditorías
g = new Guid("{a5c3defb-bcbf-41e5-aefc-2617814d25d6}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature CheckList template
g = new Guid("{63fa11ba-e8e2-414d-bb7e-a3cdbce11cfe}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature asocia eventos
g = new Guid("{bbc32500-034d-4d9e-a048-558d62edfe53}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature para crear preguntas
g = new Guid("{ee66eb41-57a4-400a-9c50-8db0e6beeb80}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature para ECB
g = new Guid("{9bbdb06c-4ea1-4328-8b3d-828ea2043d3e}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature para hallazgos
g = new Guid("{acfdda27-58d5-4f7e-a6de-0a7fe190bc74}");
if (web.Features[g] == null)
web.Features.Add(g);
//GUID de Feature para resultados
g = new Guid("{a9a804dd-18a3-47a0-80bf-25e785a8cac8}");
if (web.Features[g] == null)
web.Features.Add(g);
}
但是,我得到一个索引超出范围的异常,因为找不到它。
正如我所说,只有当主要功能通过功能标签中的站点模板激活时,才会发生这种情况。
如果我创建一个空白站点,然后激活主功能,一切都会正常工作
谢谢在启动功能接收器时,您的站点可能尚未完全配置。这意味着并非所有站点元素(例如列表模板)都可用。 作为一种解决方法,您可以实现一个 SPWebProvisioningProvider允许您控制正在设置的SPWeb(网站)或SPSite(网站集)。您可以将自己的自定义代码添加到解决方案中,而不仅仅是使用站点模板和可以通过站点模板应用的更改
来自。您可能需要为我们发布一些代码,以便更好地了解您正在做什么。
//Obteniendo el template
SPListTemplate ltAuditorias = sitio.ListTemplates["Auditoria"];