我正在尝试编写一个 Web 服务,该服务在给定其两列列表的名称的情况下在共享点站点中创建一个新列表。当我构建解决方案时,我没有收到任何错误,但是当我尝试通过客户端程序使用它时,我收到以下异常:
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
有人可以帮我吗???谷歌搜索我找到的解决方案,例如以下内容:
“回复:正在检索具有 CLSID {5D34E962-9F95-4D92-917F-F9B1A4F2BC 的组件的 COM 类工厂...
我相信您在问如何允许访问.. 抱歉,如果您不是,请执行以下操作... 在管理工具-> 组件服务下。在树下,转到组件服务->计算机->我的电脑->DCOM 配置。找到注册的 com 对象。右键单击以获取属性。在安全标签下,自定义权限以允许 asp.net 用户......希望这就是你要找的......”
响应:“Jeff,非常感谢您的快速响应……我现在面临的问题是我如何知道 com 对象是否已注册……?如果没有,我该如何注册?我知道CLSID(因为错误消息告诉我具有 CLSID {5D34E962-9F95-4D92-917F-F9B1A4F2BC6E} 的组件),但是当我查看已注册的 com 对象列表时,它没有出现。任何帮助将不胜感激。提前致谢。”
响应:“您可能实际上看不到 CLSID 下列出的类,因为它实际上可能是按其名称列出的,如果您在 Detail View 以外的任何其他地方设置了 Component Services 视图,您可能看不到它。将 View 更改为 Detail然后在 ApplicationID 列下查找此 CLSID。”
现在,即使我更改为详细信息视图,我也什么也看不到。请帮助我,在此先感谢。