Calling CoInitialize and COUninitialize in the same thread?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Moacir Schmidt

Calling CoInitialize and COUninitialize in the same thread?

Post by Moacir Schmidt » Sun 05 Dec 2004 13:23

Hi!

I'm having some problems (Acesss Violations and so on) in destruction codes of my DLL. I Have an ISAPI Application that has a pool of connections shared between several user requests. I've read that I had to call CoInitialize at begining of each thread and CoUninitialize at the end. But, I cannot CoUnitilialize the driver at the end of each thread cause the connection is part of a pool and i of course would like to reuse it in a next user request. Is there any kind of solution to this problem?

Perhaps there is no relation between couninitialize and my connection? Can I Keep the connection after a counitilialize calling?

I'm already using the latest version of the driver (2.0.3)

Moacir Schmidt

Post by Moacir Schmidt » Sun 05 Dec 2004 13:45

Well, I Think my problem has nothing to do with the correct Co(Un)Initialize balancing, I put it on the right way (at the start and the end of the thread) and still have the same problem. Access violation occurrs when another connection is peek from the pool....When the connection is created the problem does not happen, When the connection is reused, the problem does happen...

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Calling CoInitialize and COUninitialize in the same thread?

Post by Ikar » Mon 06 Dec 2004 15:53

It seems a specific of MS OLE DB working - if there is an open connection then for a thread in what it was created it is not allowed to call CoUninitialize.

Post Reply