I have a .net program that interacts with Excel spreadsheets using the standard Microsoft.Office.Interop.Excel library. The program takes a file path as a command-line argument, and it runs fine on its own.
I also have a Windows Service that implements a file listener to detect changes in a certain directory. When a new file is detected, the Excel program is called along with the file path.
This execution starts off fine, but once the Excel program tries to open the file:
wb = excel.Workbooks.Open(FileName);
it crashes with the following error:
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
Note that the code runs fine on its own, but when the program is called by the Windows service, it fails.
I've done plenty of searching for this issue, but none of the solutions I've found apply to my case. Notably, I've tried changing the component services (according to this post), but there is no Excel component in my DCOM Config at all.
Any suggestions are greatly appreciated!