2012-04-18 39 views
1

我試圖編寫一個Web服務,該服務在一個SharePoint站點中創建一個新列表其兩列的名單。當我建立的解決方案,我沒有得到任何錯誤,但是當我嘗試通過客戶端程序中,我得到下面的異常使用它:檢索具有CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F}的組件的COM類工廠失敗,原因是出現以下錯誤:80040154

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154. 
    at Microsoft.SharePoint.Library.SPRequest..ctor() 
    at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) 
    at Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) 
    at Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() 
    at Microsoft.SharePoint.SPSecurity.GetCurrentUserTokenNoApplicationPrincipalDelegated() 
    at Microsoft.SharePoint.SPSecurity.GetCurrentUserToken() 
    at Microsoft.SharePoint.SPSecurity.EnsureOriginatingUserToken() 
    at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) 
    at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) 
    at CreaListaDatoNome.Service1.CreaLista(String nomeLista, String field1, String field2) in C:\Users\Administrator\documents\visual studio 2010\Projects\CreaListaDatoNome\CreaListaDatoNome\Service1.asmx.cs:line 24 
    --- End of inner exception stack trace --- 

現在,這是Web服務的代碼:

namespace CreaListaDatoParametri 
{ 

    [WebService(Namespace = "http://tempuri.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    [System.ComponentModel.ToolboxItem(false)] 
    public class Service1 : System.Web.Services.WebService 
    { 
     [WebMethod] 
     public void CreaLista(string lista, string colonna1, string colonna2) 
     { 
      SPSecurity.RunWithElevatedPrivileges(delegate() 
      { 
       using (SPSite site = new SPSite("http://sp2010devid/sites/Chapter2/")) 
       { 
        using (SPWeb web = site.OpenWeb()) 
        { 
         site.AllowUnsafeUpdates = true; 
         web.AllowUnsafeUpdates = true; 

         // Create a new list 
         string description = "The list " +lista+ " was created via a web service"; 
         Guid idNuovaLista = web.Lists.Add(lista, description, web.ListTemplates["Custom List"]); 

         //Modify the structure 
         SPList nuovaLista = web.Lists[idNuovaLista]; 
         nuovaLista.OnQuickLaunch = true; 
         nuovaLista.EnableFolderCreation = true; 

         nuovaLista.Fields.Add(colonna1, SPFieldType.Text, true); 
         nuovaLista.Fields.Add(colonna2, SPFieldType.Text, true); 
         nuovaLista.Update(); 
        } 
       } 
      }); 
     }//end of WebMethod 
    }//end of classe 
}//end of namespace 

任何人都可以請幫我嗎? 谷歌搜索的解決方案,我發現例如以下:

"Re: Retrieving the COM class factory for component with CLSID {5D34E962-9F95-4D92-917F-F9B1A4F2BC...

I beleive you are asking how to allow access.. Sorry if you are not, but do the following... Under administrative tools->Component services. Under the tree, go to Component Services->Computers->My Computer->DCOM Config. Find the registered com object. Right click for porperties. Under the security tag, customize the Permissions to allow asp.net user... Hope this was what you were looking for..."

Response: "Jeff, thanks a lot for your quick response...the problem I am facing now is how I know if the com object is registered or not...? and if not, how can I register it? I know the CLSID (because the error message tells me the component with CLSID {5D34E962-9F95-4D92-917F-F9B1A4F2BC6E}), but when I look on the list of registered com objects it does not appear. Any help will be appreciated. Thanks in advance."

Response: "You may not actually see the class listed under the CLSID, as it may actually be listed by its name and if you have the Component Services view set on anything other than Detail View you may not see it. Change the View to Detail and then look for this CLSID unter the ApplicationID column."

現在,即使我改變詳細查看我什麼也看不見。 請幫助我,在此先感謝。

回答

4

您是否將列表添加到sharepoint 2010?如果是,您的項目的平臺構建是什麼?確保將您的客戶端應用程序構建爲64位(與SharePoint Server平臺相同)

相關問題