C# 检索CLSID为{00024500-0000-0000-C000-0000000000 46}的组件的COM类工厂失败-80080005

C# 检索CLSID为{00024500-0000-0000-C000-0000000000 46}的组件的COM类工厂失败-80080005,c#,com-interop,excel-interop,C#,Com Interop,Excel Interop,我正在使用Interop打开Excel实例以检索一些数据。但是,以下行: Application xlApp = new Microsoft.Office.Interop.Excel.Application(); 正在给出此错误: System.Runtime.InteropServices.COMException HResult=0x80080005 Message=Retrieving the COM class factory for component with CLSID

我正在使用Interop打开Excel实例以检索一些数据。但是,以下行:

Application xlApp = new Microsoft.Office.Interop.Excel.Application();
正在给出此错误:

System.Runtime.InteropServices.COMException
  HResult=0x80080005
  Message=Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
在Office被更新为Office Pro Plus之前,这项功能就可以正常工作了。在其他计算机上,通过将身份从DCOM配置更改为交互式用户,可以解决此问题

然而,我无法使它工作,尝试了其他几种解决方案(更改权限等),但似乎没有一个工作


有人遇到这个问题并设法解决了吗?

问题已经解决。看来我的办公室执照有个奇怪的问题

还必须执行以下步骤:

  • DCOM配置>Office授权COM服务器16。右键单击>属性
  • 在“标识”选项卡中,更新为“交互式用户”
  • 在“安全性”选项卡的“启动和激活权限”部分中,为用作应用程序池标识的用户授予本地启动权限

  • Web或桌面应用程序?Web应用程序这是否回答了您的问题?不,很遗憾,建议的解决方案都不起作用。您是否尝试将
    添加到
    下的
    Web.config
    文件中?这对于从C#连接到Office 365很有效,但是,我必须按照@SeM
    使用Web.config中的模拟设置