I have a .NET C# windows app that I need to read some excel data into. I have started by writing some unit tests .. one of the first just trys to instantiate a Workbook, and it is throwing this error …
System.Runtime.InteropServices.COMException: System.Runtime.InteropService.COMException: Retrieving the COM class factory for component with CLSID {GUID} failed due to the following error: 80040154 Class not registered {Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
This piece of the app is really simple, the one method,
public Workbook RetrieveWorkbook()
{
return new Workbook();
}
and one unit test that calls this function.
Code is using Microsoft.Office.Interop.Excel.
I went into the dcom config utility and verified that access seem to be correct. What am I missing? Any thoughts?
The MSDN Library article for the Workbook class constructor is quite explicit:
Use the Application.Workbooks.Add() method, sample code is here.