我正在使用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配置中的交互式用户来解决了此问题。
然而,我无法使它工作,尝试了几种其他解决方案(更改权限等),但似乎没有一个能够解决问题。
有人遇到过这个问题并设法解决了吗?
<system.web>
下的Web.config
文件中添加<identity impersonate="true" userName="AdminUser" password="Password" />
吗? - SᴇM