Author Topic: Unable to cast COM object of type Unspecified error: HRESULT: 0x80004005  (Read 1681 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
You may get the following error message with error code  HRESULT 0x80004005 when you are trying to use the COM DLL in your C# client application.

Unable to cast COM object of type 'SFTComServer.MathControlClass' to interface type 'SFTComServer.IMathControl'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B129C4F7-81EA-7DA-AA22-4120C487C3FB}' failed due to the following error: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).

You have to understand this error clearly on why it is happening. This is because  COM DLL Server does not implement IDispatch interface. For security reasons, COM developer might hide IDispatch so that It can not be used by any other clients application except their own C++ clients. C++ Clients can directly access the COM interface methods like c++ virtual functions. From C++ clients, they will include .h file and _i.c file generated by MIDL compiler.

We do not have this luxary in C# so we can not use the current COM server component in C#. If you want to use it, then you need to make changes in the COM server code to expose IDispatch interface.

good luck

For more details, visit us at: http://www.softwareandfinance.com



 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1