2008-10-30 177 views
3

我創建了一個在32位模式下運行的批處理作業,因爲它使用32位COM對象,這需要連接到SharePoint以更新列表。 它在我的開發環境中工作,因爲它是完整的32位。但在我的測試和脾淋巴細胞的環境,我們使用64位的SharePoint,這是我從獲得的SPSite:使用SPSite從32位應用程序訪問64位SharePoint

System.IO.FileNotFoundException: 
    The Web application at http://<my sp host>/ could not be found. 
    Verify that you have typed the URL correctly. 
    If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application. 

at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri req... 

這是我做的

 using (SPSite site = new SPSite(_url)) 
     { 
      using (SPWeb web = site.OpenWeb()) 
      { 
       try 
       { 
        SPList list = web.Lists[new Guid(_listID)]; 
        SPListItem item = list.GetItemById(id); 
        item[field] = value; 
        item.SystemUpdate(false); 
       } 
       catch (Exception x) 
       { 
        log.Error(x); 
       } 
      } 
     } 
+0

我的解決方法是爲我的32位COM對象創建一個webservice包裝,讓我的批處理jobb運行64位。 – walming 2008-11-05 12:29:57

回答

1

我不認爲這是一個32位/ 64位問題就像我在32位上開發和部署到64位一樣。 (實際上,我們正在運行一個32位和64位WFE)

由於從SPSite構造函數拋出異常,因此我會進一步調查您正在運行代碼的機器(SP盒)是否實際識別該網址。

+1

如果我將應用程序編譯爲64位,並且只是嘗試SPSite代碼,所有代碼都很好。所以它與64位SharePoint不允許來自32位的呼叫有關。 我可以使用web服務進行列表更新,但它總是創建一個新版本的listitem,我需要該項目具有相同的版本 – walming 2008-10-30 20:13:12

6

您只需要在64位進程中運行批處理作業。問題在於SharePoint的許多COM對象都是在測試和生產環境中爲64位編譯的。 SPSite和SPWeb對象實際上包裝了COM對象,這就是它們在32位進程中失敗的原因。

一種解決方法可能是通過其Web服務而不是對象模型與SharePoint進行交互。

+0

我需要它運行在32位模式,因爲我使用其他COM對象只能在32位模式下工作不是一種選擇。 使用SharePoint webservice不工作,因爲我需要做一個SystemUpdate,所以該項目不會得到一個新的版本。 – walming 2008-11-05 12:27:59

相關問題