DotNet As Late Bound Automation Server

  • Thread starter Thread starter Derek Hart
  • Start date Start date
D

Derek Hart

I have a vb.net application in which I have used global variables. I
converted it to become a late bound automation server (it is a dll now),
where I simply want to call it from an Access application and run it. To my
surprise, when the Access app calls the application with CreateObject, it
works fine the first time. Then I set the reference to nothing. Then I run
it again, and all the global variables are still filled with data, such as
datasets that have data in them, and they get doubled up with data! If I
closed Access and re-run it, then it is fine again. So Access actually
seems to call the same instance, even though I could swear it should be shut
down. I have seen some posts on .Net not being able to be an automation
server that easily, but this is a simple program I just want to call. Any
ideas on how to shut it down?

Derek Hart
 
The keywords for your problem could be "DLL" and "Global Variable", IMO.

Since you use it from Access app by calling "CreateObject()" in VB(A?), you
must have used the .NET DLL through Interop. From your Access app's point
view, it just a ActiveX DLL.

Since it is dll, it runs in the same process as your Access app, meaning, it
won't get unloaded until the app is closed. Not seeing your code, I do not
know how the Global Variable is declared and what object it is pointing to
and how that object is created. It is obviously, when you close (what
"Close" means here is questionale, I'll mention it later) some created by
the DLL, that object may not get destroyed. Set a varible that points to an
object to nothing DOES NOT guarrantee the object being destroyed. In your
case, there must be something that still holds reference to that object.

How do you close the thing created in your DLL (I do not call it an app or
process, since it is ActiveX DLL, part of your Access app)? Is at a Win Form
and being shown and closed? Are you sure when you close the form, all
objects related to the form are released? Also, since the said object is a
global one, obviously, closing the form has no effect to it.

IMO, the most possible source of your problem is the GLOBAL variables. I'd
always avoid to use it.
 
Back
Top