Problem with Interop between COM and unmanaged C++, firing an event from COM: TYPE_E_LIBNOTREGISTERED RRS feed

  • Question

  • Hi all,
    i have a COM (.NET) server which fire events via a observer previously set. Consuming client is a unmanaged C++ Dll.
    Client makes CoInitialize, CreateInstance, MyCOMServer::Initialize(), MyCOMServer::RunSomeMethod() and MyCOMServer::SetObserver( IMyObserver observer ) successfully.
    But when server tries to fire an event via m_observer.MyEvent(), next exception is thrown:

    InvalidCastException - Unable to cast COM object of type 'System.__ComObject' to interface type 'MyCOMServerModule.IMyObserver'.  This operation failed because the QueryInterface call on the COM component for the interface with IID '{AB48506A-8D18-3CCE-BF55-F45CA3FB9171}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

    GUID is ok, calls to QueryInterface are executed ok, NET Framework 2.0 is installed.
    My sample app works properly in some hosts, but fails in one, and i would like to know why, but i cant figure it out.
    I tried to re-install .NET 2.0, but nothing.

    Can someone please help?
    Thank you.

    Wednesday, February 25, 2009 9:57 AM


  • The error message gives a pretty good hint.  Dig through the HKCR\Typelib registry key to see if the type library is properly registered.  Observing the process with SysInternals' ProcMon utility can gives lots of troubleshooting hints too.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, March 2, 2009 10:30 AM
    Wednesday, February 25, 2009 12:35 PM