I have a program that runs on a SBS 2008 server which has Office 2007 installed and creates a report in an Excel file that is emailed. I'm using NetOffice to create the Excel file and it works most times. However, it's regularly throwing a File Not Found exception and failing.
The full exception is:
Inner Exception:System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E). at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType) at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType) at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj) 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.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NetOffice.COMObject.CreateFromProgId(String progId, Boolean factoryAddObject) Source: NetOffice Stack Trace: at NetOffice.COMObject.CreateFromProgId(String progId, Boolean factoryAddObject) at NetOffice.ExcelApi.Application..ctor(Boolean enableProxyService) at NetOffice.ExcelApi.Application..ctor() at CCDExceptionReport.Program.Main(String[] args) Target Site: Void CreateFromProgId(System.String, Boolean)
If I immediately re-run the program it will always run successfully.
I have tried doing a rebuild all, replacing the files on the server, compiling in VS 2019 and 2017.