Sometimes GetActiveObject does not work...

Sometimes GetActiveObject does not work...

oransen
Collaborator Collaborator
727 Views
2 Replies
Message 1 of 3

Sometimes GetActiveObject does not work...

oransen
Collaborator
Collaborator

When starting up sometimes GetActiveObject does not get hold of an already running Inventor.

 

I'm testing a program which uses a part which the program assumes is already loaded, but since GetActiveObject fails the whole program fails.

 

What could make GetActiveObject fail if a session is already open?

 

    CLSID InvAppClsid; 
    HRESULT hRes = CLSIDFromProgID (L"Inventor.Application", &InvAppClsid);
    if (FAILED(hRes)) {
        pInvApp = nullptr ;
        return ReturnAndShowCOMError (hRes,L"ConnectToInventor,CLSIDFromProgID failed") ;
    }

    // See if Inventor is already running...
    CComPtr<IUnknown> pInvAppUnk = nullptr ;
    hRes = ::GetActiveObject (InvAppClsid, NULL, &pInvAppUnk);
    if (FAILED (hRes)) {
        // ERROR: Inventor IS running but GetActiveObject fails
        // What can I do to investigate this error?

The COM error code is 0X800401E3.

 

The meaning is "operation not available" (translated from Italian).

 

 

 

0 Likes
728 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni

It's difficult to say what the problem is.  Connecting to Inventor's API using GetActiveObject is all Microsoft functionality.  Are you running on any kind of "special" system?  For example, is it a server?  I've seen some strange behavior before with that.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 3

oransen
Collaborator
Collaborator

I've investigated further and it seems to be a (known) (Microsoft) problem with the ROT (Running Objects Table). If I get any further with this I'll report back here.

 

0 Likes