Hi Guys,
I am trying to create a program that creates Excel files on the fly.
More info on what I am working with is here:
http://csharp.net-informations.com/excel/csharp-create-excel.htm
Now, locally all works fine, but on staging server, I am getting an exception:
System.Runtime.InteropServices.COMException (0x80040154): 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)). at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Samfund.CustomModules.Excel.ExcelHelper.GenerateExcel(TempOrder order) in C:\Users\Dmitrij\Source\Repos\sam\Samfund\CustomModules\Excel\ExcelHelper.cs:line 24 at CompiledRazorTemplates.Dynamic.ceeeceaabeeaea.Execute()
Now it is quite clear where the issue happens:
Codeline: 24 of ExcelHelper.cs class - and here it is:
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
It is where I initiate Excel object class.
In order for this to work I had to reference a COM dll into a projecect.
Since that is local project, I just referenced it in the code, and DLL was created. But I am unsure regarding this COM dll on the productsion server.
In the project DLLs there is no Microsoft.Office DLL that I had to add, so I am not sure where to get it from...
If you have any Tips on this, would greatly appreicate that.
/Dmitrij