我有一個自定義網站模板,它激活一個帶有事件接收器的特性,接收器唯一做的就是激活一些其他特性,全部在同一個接收器中。通過SharePoint 2007中的事件接收器找不到SPListTemplate
我激活的第一個功能是名爲「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"];
不過,我得到一個索引超出範圍的異常,因爲它沒有發現。 正如我所說的,只有當主要功能通過功能標籤中的站點模板激活時纔會發生。 如果我創建一個空白網站,然後激活主要功能,一切正常。
感謝
您可能需要發佈一些代碼才能更好地瞭解您正在做的事情。 – Nat 2011-03-22 20:33:33