2014-02-25 17 views
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; 
      } 
     } 
    }); 

} 

回答

0

問題就解決了,這是不可能激活相同的功能,其功能安裝時,安裝功能時。因此,我使用了稱爲功能裝訂的方法,該功能在部署解決方案時安裝並工作。

相關問題