0

when i run my code on local, no problem.. but when i run my code on the server, i take this error:

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

it gives the error in this line:

excelObj = new Microsoft.Office.Interop.Excel.Application();

this is description:

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");

is this error related to my code or my server?

thanks in advance..enter image description here

rockenpeace
  • 1,011
  • 5
  • 18
  • 29
  • 4
    You know that server-side (i.e. ASP.NET) regular Office COM interop isn't a supported use-case / licensing-model, right? [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.](http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2) – Marc Gravell Aug 06 '12 at 08:44
  • 1
    Do you have Office installed on the server? – Sjoerd Aug 06 '12 at 08:45
  • i use office 2010 professional trial version.. – rockenpeace Aug 06 '12 at 08:47

1 Answers1

3

It means the Excel Interop assembly is not registered on the production server. That's good, because you don't really want to use Office interop in automated environments (like ASP.NET). Check the article for alternatives.

just.another.programmer
  • 8,579
  • 8
  • 51
  • 90