当我在本地运行我的代码时,没有问题..但是当我在服务器上运行我的代码时,我接受了这个错误:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
它给出了这行中的错误:
excelObj = new Microsoft.Office.Interop.Excel.Application();
这是描述:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Source Error:
Line 169: Microsoft.Office.Interop.Excel.Workbook workbook = null;
Line 170:
Line 171: excelObj = new Microsoft.Office.Interop.Excel.Application();
Line 172:
Line 173: System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
此错误与我的代码或服务器有关吗?
提前致谢..
答案 0 :(得分:3)
这意味着Excel Interop程序集未在生产服务器上注册。这很好,因为您在自动化环境(如ASP.NET)中don't really want to use Office互操作。检查文章中的替代品。