views:

93

answers:

2

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);

A: 

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.

MCain
no. he's using reflection, so why would he need to add a reference to the PIA?
Anonymous Type
A: 

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.

Hans Passant
you could also try runningExcel.exe /safeto load Excel while disabling things like addins and see if it loads ok. Then if that works try unticking (disabling) selected addins (COM and Excel) as well as disabling any VBA macros.
Anonymous Type