【发布时间】:2011-03-23 16:07:23
【问题描述】:
我有一个自定义站点模板,它通过事件接收器激活一个功能,接收器唯一要做的就是激活一些其他功能,所有这些都在同一个接收器中。
我激活的第一个功能是一个名为“Audits”的 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);
}
第一个功能是列表模板。 第三个功能有一个接收器,我在其中寻找模板
//Obteniendo el template
SPListTemplate ltAuditorias = sitio.ListTemplates["Auditoria"];
但是,我得到一个索引超出范围异常,因为它没有找到。 正如我所说,只有在通过 Feature 标签中的站点模板激活主要功能时才会发生这种情况。 如果我创建一个空白网站,然后激活主要功能,一切正常。
谢谢
【问题讨论】:
-
您可能需要发布一些代码让我们更好地了解您在做什么。
标签: sharepoint sharepoint-2007