开发者

COMException when creating COM object for Excel Automation in C#

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.Runtim开发者_StackOverflow社区e.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);


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜