B
Bendik Engebretsen
My main project is an MFC application. Its document class derives from
COleServerDoc and I have implemented an Automation interface based on
IDispatch. I am using VisualBasic to test the Automation interface. After
moving to VB.NET, I have gotten into trouble when releasing my document
objects.
Earlier, I used the syntax
MyDoc = Nothing
to tell that the document had been closed in the server application and that
the object was no longer valid. With VB.NET, this doesn't seem to work in
the same way. It appears that the object is still 'in use' somehow after
this statement, and I get different kind of errors in VB if my server cleans
up ('delete this') the document object. If I leave the MFC document object,
everything seems to work fine, except that the document object is left in
memory - and thus the server application will also be left in memory after
exiting the VB client.
I have now read just a little bit about the garbage collection mechanism in
VB.NET, and suspects that this has something to do with the problem. The VB
object is not actually released when you say "= Nothing", right ?.
My question is: Will it help implementing an IDisposable interface on my
document object (in MFC) ? Will VB.NET be able to see it and use it ? Could
I then call .Dispose() directly to make sure the document object is released
? Or is there some other way in VB to explicitly dispose the object ?
Appreciate any help or clues whatsoever!
Bendik
COleServerDoc and I have implemented an Automation interface based on
IDispatch. I am using VisualBasic to test the Automation interface. After
moving to VB.NET, I have gotten into trouble when releasing my document
objects.
Earlier, I used the syntax
MyDoc = Nothing
to tell that the document had been closed in the server application and that
the object was no longer valid. With VB.NET, this doesn't seem to work in
the same way. It appears that the object is still 'in use' somehow after
this statement, and I get different kind of errors in VB if my server cleans
up ('delete this') the document object. If I leave the MFC document object,
everything seems to work fine, except that the document object is left in
memory - and thus the server application will also be left in memory after
exiting the VB client.
I have now read just a little bit about the garbage collection mechanism in
VB.NET, and suspects that this has something to do with the problem. The VB
object is not actually released when you say "= Nothing", right ?.
My question is: Will it help implementing an IDisposable interface on my
document object (in MFC) ? Will VB.NET be able to see it and use it ? Could
I then call .Dispose() directly to make sure the document object is released
? Or is there some other way in VB to explicitly dispose the object ?
Appreciate any help or clues whatsoever!
Bendik