0
由於我必須以編程方式激活Sharepoint網站集功能,因此我已將FeatureEventReceiver添加到解決方案中。這裏是我的代碼,部署步驟'添加解決方案'時發生錯誤:此服務器場中未安裝Id'guid'的功能,並且無法將其添加到此範圍。
public override void FeatureInstalled(SPFeatureReceiverProperties properties) {
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://itcdev33"))
{
using (SPWeb web = site.RootWeb)
{
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates = true;
Guid myid = new Guid("32529c03-833d-4c5e-a15e-0bcb35bdedad");
if (site.Features[myid] == null)
{
site.Features.Add(myid, true, SPFeatureDefinitionScope.Site);
}
web.Update();
site.AllowUnsafeUpdates = false;
web.AllowUnsafeUpdates = false;
}
}
});
}