Wierd com behavior
Posted on 2002-04-04
k, here is what I do, and I'd like to know why.
1. I create a stock COM project (dll) (lets call it TestProj) with 1 object in it that is both free threaded and custom interface (lets call it TestFC).
2. I create a stock COM project (exe) with no objects in it (lets call it TestRunProj).
3. #import "testproj.tlb" no_namespace, named_guids
4. I add the following code right before the msg loop in the exe.
HRESULT hr = m_pTestLink.CoCreateInstance( CLSID_TestFC );
if ( TRUE == FAILED( hr ) )
ATLTRACE("Failed %x\n", hr );
} // End try
catch( _com_error e )
HRESULT hr = e.Error();
ATLTRACE("Com Error %x\n", hr );
} // End catch
5. run it.
I ALWAYS get a failure to create the INTERFACE. However, if I change either the free threading to apartment OR the custom interface to dual, it WORKS. wtf is going on here. Why in the world would this be happening? This is even further disturbing because the final construct and final release both happen on the object.