Call DotNet Application From Access - Cannot Release Dotnet Application

D

Derek Hart

Help!



I cannot get my DotNet application to shut down as an automation server from
Access.



I have the following simple code in Access that I am using to call a VB.NET
application:



Dim w As Object
Set w = CreateObject("MyProgram.MyProgramClass")
w.MyProgramDoSomething
Set w = Nothing



I have tried many things in DotNet. The final lines of the application are
the following:



System.GC.Collect()

System.GC.WaitForPendingFinalizers()



When I run the above code in Access to call the program, it runs it, which
opens up a DotNet WindowsForm, and then I shut down the WindowsForm, and
when I run the Access code again, it runs the DotNet app again, but the
DotNet app was never fully released. For example, Datasets that were filled
with data get added to, and the data is doubled! Task manager does not show
that the program is running, but Access still holds a connection. By the
way, if I exit Access and open it up again and run the above code, it works
fine. How do I properly exit the DotNet app?



Thank You,

Derek Hart
 
T

TC

From my viewpoint as an Access VBA guy, that should work fine. (But I
don't know anything about .NET.)

How about this as a long shot. Access itself has a property,
UserControl, of the Application object. If you automate Access, and
make the automated instance visible, then set UserControl=true, that
instance will not go away when you set the object variable to nothing.
So maybe, .NET (or its forms) has a similar property, which is
automagically set True when the instance becomes visible? If so, maybe
you could set that property back False before you drop the object
reference.

As I say, this is nothing more than a stab in the dark.

(Snipped microsoft.public.access.modulescoding, cos google groups would
not post there.)

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top