打开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

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

问题描述

我有一个C#.NET Web应用程序。我希望用户点击网页上,服务器打开一个Excel电子表格和写入数据到它,用户保存文档的按钮。这个工程在本地使用Visual Studio 2010和Office 2010。在我的服务器,但是,我得到这个错误:




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




我已经研究并发现一吨的答案,说明打开dcomconfig和权限到Microsoft Excel应用程序添加的用户。我的网站设置为直通安全,所以我说我自己;我是在服务器上管理员,所以我保证管理员得以进入;我还添加了网络服务的应用程序池默认值;还ASP.NET计算机帐户;并且,为了以防万一,添加连接到数据库时,应用程序使用的帐户。我仍然得到确切的同样的错误。



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



我的代码是:

  {

{
Excel.Application XXL = NULL;
Excel.Workbook XWB = NULL;
Excel.Worksheet xSheet = NULL;
XXL =新Excel.Application();
}
赶上(异常前)
{
的Response.Write(ex.ToString());
}
}


解决方案

办公室自动化 - 这些Excel.Application和Excel.Workbook对象的用法 - 不建议和不是由微软。你看:




微软目前并不提倡,不支持,Microsoft Office应用程序的自动化,从任何无人参与的非交互式客户端应用程序或组件(包括ASP,ASP.NET,DCOM和NT服务),因为Office可能会出现不稳定的行为和/或办公室时,在这种环境中运行死锁。




这意味着,即使哟理清你的服务器端/客户端的问题,你还在玩火,因为有些情况下可能的工作,别人也不会和其他人有时会和有时会导致你的过程挂起,因为Excel试图打开一个弹出通知时,没有登录到服务器控制台的用户。相信我,不这样做。



链接我提供的名单几个选择给你想要做什么,但假设你正在计划建设相对简单Excel表的用户,你最好只是创建 CSV文件和发送该回用适当的头中的用户(类似 Response.ContentType =应用程序/ vnd.ms - Excel的),以便返回的数据将被Excel默认打开。
你可以看到更多的答案在这里,问题的


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());
        }
    }

解决方案

Office automation - the usage of these Excel.Application and Excel.Workbook objects - is not recommended and not supported by Microsoft. Look:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

This means that even if yo sort out your server-side/client-side issues, you're still playing with fire, since some scenarios might work, others won't, and others will sometimes work and sometimes cause your process to hang because Excel attempts to open a pop-up notification when there isn't a console user logged onto the server. Trust me, don't do it.

The link I provided lists several alternatives to what you're trying to do, but assuming you're planning on building relatively simple Excel sheets for your user, you're better off just creating a CSV file and sending that back to the user with the appropriate header (something like Response.ContentType="application/vnd.ms-excel") so that the returned data will be opened by Excel by default. You can see more answers to that question here.

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

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