2012-04-18 127 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平台相同)

相关问题