我尝试在服务器端使用Microsoft.Office.Interop.Excel.Workbook
类将.xls文件转换为.xlsx文件,如下所示:
workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
我得到了以下错误:
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)). : System.Runtime.InteropServices.COMException (0x80080005): 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)).
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)
at CALLING_METHOD_IN_MY_LIBRARY_HERE...
问题是这个错误只发生在临时服务器上;在我的本地机器上它工作得很好。
我在临时服务器上尝试过的内容:
2)展开组件服务"->“Computer "->”My Computer "->“DCOM configuration”
3)找到"Microsoft Excel应用程序“。
4)打开属性对话框的权限
5)点击“安全”标签,
6)“启动和激活权限,配置权限,已添加权限-在管理员用户(此用户)、交互用户和启动用户下运行的身份
7)。启动和激活权限+访问权限+配置权限=>增加了完全控制的IIS_IUSRS +网络服务**
有人想出了解决这个问题的办法吗?我正在努力解决这个问题已经2天了。
发布于 2016-09-27 20:43:49
使用DCOMCNFG.exe。打开它,然后转到: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application。
打开属性,选择身份选项卡,然后选择交互式用户。
发布于 2019-03-11 18:23:15
我在别的地方找到了解决方案。
执行以下,确实解决了我的问题:
使用DCOMCNFG.exe的
。打开它,然后转到: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application。打开属性,选择身份选项卡,然后选择交互式用户。
但是--这个问题每隔几分钟就会出现一次!
在试图找出原因的几个小时后,我注意到我的服务器有数百个打开的WINWORD.EXE进程。这导致内存问题,从而导致exception from hresult 0x80080005
错误。
好吧,非常愚蠢的是,我忘记编写代码来关闭互操作应用程序。一旦我解决了这个问题,这个错误就消失了。
doc.Close(false);
Marshal.ReleaseComObject(doc);
word.Quit();
Marshal.ReleaseComObject(word);
发布于 2018-02-01 20:01:52
我发现这篇文章更深入地讨论了这个问题,如果这有帮助,错误“80080005服务器执行失败(来自HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)的异常)”可能由于以下原因而发生:
重新验证此信息
https://stackoverflow.com/questions/22062284
复制相似问题