1
votes

I've got this error when I create a COM object in order to use Excel automation. Any one knows why I am getting this error?

System.Runtime.InteropServices.COMException(errorCode = -2146959355) Message: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005.

The call stack is following:

System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType) at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(Type objectType) at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type serverType) at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj) at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at Geotab.ComObject..ctor(Type type)

This is my code: Type excelAppType = Type.GetTypeFromProgID("Excel.Application"); comExcelObject = new ComObject(excelAppType);

2

2 Answers

0
votes

The error code (0x80080005) is CO_E_SERVER_EXEC_FAILURE, "Server execution failed". In other words, something went wrong when COM tried to start Excel.exe. Pretty basic problem that has way too many possible causes. Check the Windows event log for a possible better diagnostic. The usual next step is reinstalling Office.

0
votes

You need a reference to the Excel library. Add Reference on your project and go to the COM tab, then Microsoft Excel with the version you have.