打开excel错误:System.Runtime.InteropServices.COMException(0x80080005):使用CLSID检索组件的COM类工厂 [英] opening excel error: System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID

查看:1690
本文介绍了打开excel错误:System.Runtime.InteropServices.COMException(0x80080005):使用CLSID检索组件的COM类工厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#.net网络应用程序。我想让用户点击网页上的一个按钮,服务器打开一个excel电子表格并写入数据给用户,并保存该用户的文档。这在本地使用Visual Studio 2010和Office 2010.在我的服务器上,但是,我得到这个错误:


System.Runtime.InteropServices。 COMException(0x80080005):由于以下错误,检索CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败:80080005服务器执行失败(HRESULT异常:0x80080005(CO_E_SERVER_EXEC_FAILURE))。


我已经研究并发现了大量答案,说明打开dcomconfig并将具有权限的用户添加到Microsoft Excel应用程序。我的网站设置为通过安全,所以我补充说自己;我是服务器上的管理员,所以我确保管理员有权限访问;我还添加了App Pool默认的网络服务;还有ASP.NET机器帐号;并且,以防万一,添加了应用程序在连接到数据库时使用的帐户。我仍然得到完全相同的错误。



我的服务器是64位,Office 2007,IIS 7.



我的代码是:

  {
try
{
Excel.Application xXL = null;
Excel.Workbook xWB = null;
Excel.Worksheet xSheet = null;
xXL = new Excel.Application();
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}


解决方案


  1. 在DCOMCNFG中,右键单击我的电脑并选择属性。

  2. 转到Component / MyComputer / DCOMConfig

  3. 转到Microsoft Excel应用程序属性安全性

  4. 在启动和激活权限,点击Custamize并添加网络服务,并给予本地启动和本地激活权限。给予相同的权限和配置权限
    按OK并确定。我现在可以运行我的应用程序。


I have a C# .net web app. I want a user to click a button on a webpage, the server to open an excel spreadsheet and write data to it, and the user to save the document. This works locally using Visual Studio 2010 and Office 2010. On my server, however, I get this error:

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)).

I have researched and found a ton of answers stating to open dcomconfig and add the user with permissions to Microsoft Excel Application. My site is set to passthrough security so I added myself; I am an admin on the server, so I ensured Admins had access; I also added the App Pool default of Network Service; also ASP.NET Machine Account; and, just in case, added the account the app uses when connecting to the database. I still get the exact same error.

My server is 64 bit, Office 2007, IIS 7.

My code is:

    {
        try
        {
            Excel.Application xXL = null;
            Excel.Workbook xWB = null;
            Excel.Worksheet xSheet = null;
            xXL = new Excel.Application();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }

解决方案

  1. In DCOMCNFG, right click on the My Computer and select properties.
  2. Go to Component /MyComputer/DCOMConfig
  3. Go to Microsoft Excel Application property Security
  4. In launch and Activation Permissions, click "Custamize" and add Network Service to it and give it "Local launch" and "Local Activation" permission. give same As Acess Permissions and cofiguration Permissions Press OK and thats it. i can run my application now.

这篇关于打开excel错误:System.Runtime.InteropServices.COMException(0x80080005):使用CLSID检索组件的COM类工厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆