2013-04-11 66 views
1

我試圖在我們的Sharepoint解決方案中實現一個插件架構,此時管理員可以上傳將由我們的解決方案安裝和處理的dll文件。GacInstall在Sharepoint計時器作業a.k.a SPJobDefinition

實現需要GAC安裝上傳的DLL文件的,我已經使用

private void InstallToGac(byte[] libraryContent, string filename) 
     { 
      string path = tempFolder + filename; 
      File.WriteAllBytes(path, libraryContent); 
      try 
      { 
       new System.EnterpriseServices.Internal.Publish().GacInstall(path); 
      } 
      catch (Exception ex) 
      { 
       Logger.Error("Error while installing dll to GAC.", ex); 
       throw; 
      } 
      finally 
      { 
       File.Delete(path); 
      } 
     } 

這只是安裝DLL到GAC,如果它的Sharepoint內部調用工作正常完成。但是,它不適用於多服務器環境,因爲這隻會將其安裝在管理員上傳文件的前端。因此,我通過繼承SPJobDefinition將上面的代碼移到了計時器作業中。 GacInstall不再安裝dll到GAC了。在調試模式下,GacInstall行工作正常,沒有任何異常,但沒有任何影響。

System.Security.Principal.WindowsIdentity.GetCurrent().Name; 

在計時器作業中返回Network Service。我在單服務器Sharepoint 2010 Foundation上工作,但我需要在單服務器和多服務器環境上工作於2007/2010/2013。

回答

0

變成Network Service一直是問題。我不認爲這是一個問題,因爲我的所有SharePoint應用程序池通過網絡服務運行,並以某種方式正常運行。更改「本地服務」上的「Sharepoint 2010定時器」服務的「登錄爲」固定它。

另外,事實證明GacInstall(path)在某些情況下不會拋出異常(包括此錯誤),並生成沒有提及的有用信息的Windows事件here

相關問題