异常调用Excel.Interop

时间:2018-11-01 15:09:20

标签: asp.net excel com interop

打开Excel工作簿时出现生产问题。抛出的异常是:

由于以下错误,检索具有CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败。

事件查看器错误日志的详细信息是:

Log Name:      Application
Source:        ASP.NET 2.0.50727.0
Date:          01/11/2018 11:50:32 a.m.
Event ID:      1309
Task Category: Web Event
Level:         Warning
Keywords:      Classic
User:          N/A
Computer:      XXXXX
Description:
Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 01/11/2018 11:50:32 a.m. 
Event time (UTC): 01/11/2018 02:50:32 p.m. 
Event ID: 6ab432cf79584f7a96bb12defe163827 
Event sequence: 849 
Event occurrence: 17 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT-2-131855513563546112 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\wwwroot\Servicio\ 
    Machine name: XXXXX 

Process information: 
    Process ID: 4460 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\Servicio 

Exception information: 
    Exception type: COMException 
    Exception message: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005. 

Request information: 
    Request URL: http://servicio.honda.com.ar/xxxx.aspx 
    Request path: /xxxx.aspx 
    User host address: 10.138.204.69 
    User: XXXX.                                                                                      |XX|0                             |0|1|652 
    Is authenticated: True 
    Authentication Type: Forms 
    Thread account name: IIS APPPOOL\Servicio 

Thread information: 
    Thread ID: 15 
    Thread account name: IIS APPPOOL\Servicio 
    Is impersonating: False 
    Stack trace:    at IngresoServicio.Upload() in c:\inetpub\wwwroot\xxx\xxxx.aspx.cs:line 131
   at IngresoServicio.ImageButtonImportar_Click(Object sender, ImageClickEventArgs e) in c:\inetpub\wwwroot\xxx\xxxx.aspx.cs:line 63
   at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
   at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

我按照"Retrieving the COM class factory for component.... error: 80070005 Access is denied." (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))的步骤进行操作,但还是会出错。

我想念什么?

最好的问候

1 个答案:

答案 0 :(得分:0)

您似乎正在尝试在服务器上使用Excel自动化。这是不受支持的用例。实际上,这已经被许多人尝试和失败了很多次,以至于目前答案是众所周知的-不要在服务器上自动化Office产品。永远期。这是Microsoft和开发人员社区的正式答案。研究可以将文档作为数据文件创建,读取或操作的工具,例如Open XML SDK。 (如果您要使用Open XML SDK,我强烈建议您在downloading the SDK时也下载Productivity工具。)