|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
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.
"Derek Hart" <derekmhart[ at ]yahoo.com> wrote in message news:O1NzWG19FHA.740[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text] >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 >
|
|
Is the other issue, whether it is a "single instance" object or not? If you CreateObject() a multiple instance object, you get a brand new copy of that object, ignoring any copies that are already running. But if you CreateObject a single instance object, and a copy is already running, get a reference to that existing copy. Or somesuch.
Yes? No?
TC
(snipped groups for google post acceptance)
|
|
|