为 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件检索 COM class 工厂失败

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed

我正在尝试读取从第 3 方站点下载的 .xls 文件。我不会每天都处理文件,所以我无法在上传文件之前将格式更改为 .xlsx

我不断收到以下错误: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

我正在 vb.net 网站上使用 IIS7。 应用程序池使用我的用户登录,我的用户是服务器上的管理员,可以访问所有内容。

我做了以下事情:

这是我的代码的样子:

Imports genlib

Imports Excel = Microsoft.Office.Interop.Excel

Partial Class HeadOffice_OpperationalParameters_FailedBranches
    Inherits System.Web.UI.Page

    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        Finally
            GC.Collect()
        End Try
    End Sub

    Protected Sub btnRunReport_Click(sender As Object, e As EventArgs) Handles btnRunReport.Click
        If fuReport.HasFile = False Then
            ClientScript.RegisterClientScriptBlock(Me.GetType, "", "alert('Upload a file to process.');", True)
            Exit Sub
        End If

        Dim ReportFileName As String = Server.MapPath("~") & "FilesUploaded\" & fuReport.FileName.Replace(".XLS", "_" & Today.ToString("yyyy.MM.dd") & "_" & TimeOfDay.ToString("HH.mm.ss") & ".xls")
        fuReport.SaveAs(ReportFileName)

        Dim xlApp As Excel.Application 'Here
        Dim xlWorkbook As Excel.Workbook
        Dim xlWorksheet As Excel.Worksheet

        Try
        '=================================================
        ' ERROR OCCURS ON NEXT LINE
        '=================================================
            xlApp = New Excel.ApplicationClass
            xlWorkbook = xlApp.Workbooks.Open(ReportFileName)
            xlWorksheet = xlWorkbook.Worksheets("RptTransactionDetail")

            BrowserWrite(xlWorksheet.Cells(2, 2).value, True)
            xlWorkbook.Close()
            xlApp.Quit()
        Catch ex As Exception
            ClientScript.RegisterClientScriptBlock(Me.GetType, "", "alert('" & ex.Message.Replace("'", "\'").Replace(vbCr, "\r").Replace(vbLf, "\n") & "');", True)
            Exit Sub
        End Try

        releaseObject(xlApp)
        releaseObject(xlWorkbook)
        releaseObject(xlWorksheet)

    End Sub
End Class

谁能告诉我如何解决这个错误,或者要采取什么步骤来确定问题?

我已经阅读了关于堆栈溢出的大部分帖子,但是太多了,无法添加我看过的每个答案。

I am using a vb.net site with IIS7

Microsoft 目前不推荐也不支持来自任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT)的 Microsoft Office 应用程序自动化服务),因为当 Office 在此环境中 运行 时,Office 可能表现出不稳定的行为 and/or 死锁。

如果您正在构建 运行 在服务器端上下文中的解决方案,您应该尝试使用已针对无人值守执行安全处理的组件。或者,您应该尝试找到至少允许 运行 客户端部分代码的替代方案。如果您从服务器端解决方案使用 Office 应用程序,该应用程序将缺少许多 运行 成功所必需的功能。此外,您将承担整体解决方案稳定性的风险。在 Considerations for server-side Automation of Office 文章中阅读更多相关信息。

如果您只处理打开的 XML 文档,您可以考虑使用 Open XML SDK 作为一种可能的解决方法,请参阅 Welcome to the Open XML SDK 2.5 for Office。或者只是为服务器端执行而设计的任何第三方组件(例如,Aspose)。