Link to home
Start Free TrialLog in
Avatar of danielsson
danielssonFlag for Germany

asked on

CoCreateInstance hangs - possible reasons?

Hello there,

Under certain circumstances, a CoCreateInstance call hangs my application. As it seems after some other parts of my program uses COM interfaces and such. I am trying to instanciate an object like this:

      HRESULT hresult;
      CLSID clsid;
      
      // initialize COM
      hresult = CoInitialize(NULL);

      // get component CLSID
        if (SUCCEEDED(hresult))
           hresult = CLSIDFromProgID(OLESTR("mydll.CMyComClass"), &clsid);
      
      // the class we defined in dll
      mydll::_CMyComClass *t;
      
      // create a class instance
      if (SUCCEEDED(hresult))
         hresult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
            __uuidof(mydll::_CMyComClass), (LPVOID *) &t);

      [ ... ]

Before other COM calls have been made, this code works perfectly. Afterwards, the CoCreateInstance() call hangs my application each and every time. It never comes back. No error message, it's just that nothing happens.

Any ideas? Urgent!
ASKER CERTIFIED SOLUTION
Avatar of KurtVon
KurtVon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danielsson

ASKER

Thanks guys, I'll try to evaluate your hints in the next couple of days. Right now I've run into a bunch of other things... as always.
Avatar of Milind00
Milind00

On What OS you are running this code?
And Is this code gets executed before the entry point? I mean before main ()?