p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

activex_data_objects thread: Implementing ADO in an MFC application ...


Message #1 by "Tom Bellavia" <tbellavia@v...> on Fri, 27 Apr 2001 23:32:19
I am utilizing ADO in my Visual C++ application (MFC) and it appears that 

the interface pointers are being released without being valid any longer 

when closing the app. It seems the references are becoming unstable. I am 

just calling a series of functions after initializing COM to load database 

values from an .mdb database. I then call Uninitialize() to unload the 

libraries.

The function that generates this unhandled exception is in Release(). This 

is called from every instance creation and scope change. However, I never 

see an AddRef() being called. 

Has anyone ever had to deal with interface pointers and experienced this 

problem? If so, you could be saving my life. :)

One other thing to note is that I am using smart pointers as well as 

QueryInterface methods (not at the same time.)

TCB
Message #2 by "Pete Davis" <pdavis@q...> on Sat, 28 Apr 2001 11:08:31 -0400
Smart pointers release the object as soon as they go out of scope. That

means that, if you create a COM instance with a pointer in a function, as

soon as you the function returns, the COM object is released. The same goes

for an application. If you have a global smart pointer, or one that is, say,

in the constructor for the app, it will go out of scope on termination of

the program and therefore will be released.



Hope that answers your question.



Pete

----- Original Message -----

From: "Tom Bellavia" <tbellavia@v...>

To: "ActiveX_Data_Objects" <activex_data_objects@p...>

Sent: Friday, April 27, 2001 11:32 PM

Subject: [activex_data_objects] Implementing ADO in an MFC application ...





> I am utilizing ADO in my Visual C++ application (MFC) and it appears that

> the interface pointers are being released without being valid any longer

> when closing the app. It seems the references are becoming unstable. I am

> just calling a series of functions after initializing COM to load database

> values from an .mdb database. I then call Uninitialize() to unload the

> libraries.

> The function that generates this unhandled exception is in Release(). This

> is called from every instance creation and scope change. However, I never

> see an AddRef() being called.

> Has anyone ever had to deal with interface pointers and experienced this

> problem? If so, you could be saving my life. :)

> One other thing to note is that I am using smart pointers as well as

> QueryInterface methods (not at the same time.)

> TCB

>

  Return to Index