Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application




Stephen Howe wrote:
The following is an excerpt from the code:
::Coinitialize(NULL)
Thank you for answer.
I changed the code. Now I'm using CoInitializeEx() instead of
Coinitialize(NULL):
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup
COM lib
if(FAILED(hr))
debug (" Multithread initialization failed");

The result is S_OK. Of course, the CoUninitialize() function remained
at the end of the thread function.
Invalid Handle doesn't appear at CoUninitialize() function on this
thread, but it appears at CoUnitialize() function from the main thread.
The application has a main thread where the same CoIntializeEx with the
same parameters as in code for the thread that I showed you is called.
Also, CoUninitialize() is called at the end of application on the same
main thread. So practically, instead of giving "Invalid Handle" at the
end of the thread on CoUninitialize(), now it gives at the end of
application on CoUninitialize().
CoInitializeEx isn't called on any other thread from this application.
I'll try to be as clear as possible. Here are somehow the steps for the
thread that uses ADO and the main thread which creats it:

/*Main thread*/
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup COM
lib
if(FAILED(hr))
debug (" Multithread initialization failed");
//lot of code//
m_hDrvThread = CreateThread( NULL, NULL, ThreadFnc, (LPVOID)poi, 0,
&dwId);
/*Function for the thread which uses ADO*/
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); //
setup COM lib
if(FAILED(hr))
debug (" Multithread initialization failed");
//code that I wrote on the first post
CoUninitialize();
/*end of Function for the thread which uses ADO*/
CoUninitialize(); //here, when debugged with Application Verifier and
WinDbg an exception with "Invalid Handle" raises
/*End of Main thread*/

.



Relevant Pages

  • Static Library Containing Dialog and Resource
    ... I have a static library that links with the static MFC lib. ... Everything works great with the debug build. ... But when the calling app that links in the ... Access Violation - nothing odd shows up in the debug build. ...
    (microsoft.public.vc.mfc)
  • Re: Another stupid MSVC6 linking problem
    ... I compile and link in Release mode, ... What could cause this type of difference between Release and Debug? ... Or you changed function calling convention. ... Or you should really include some other lib, ...
    (microsoft.public.vc.mfc)
  • Re: Different C runtime libraries
    ... For example the debug and release CRT ... > version should have exactly the same interface. ... .LIB should be only seen as a bunch of .OBJ ... passes it to fprintf which fprintf should be called? ...
    (microsoft.public.vc.language)
  • Re: Problems with boost::filesystem and QT?
    ... I don't think that msvcrt is the debug version of the crt lib. ... Just telling the IDE to ignore the lib still lets me debug the CRT ...
    (microsoft.public.vc.language)
  • CoUninitialize hanged when create com object in CDOEXM.dll
    ... IExchangeServer, then when call CoUninitialize, if in debug step by step ... // this will hang the program ...
    (microsoft.public.exchange.development)