Killing Access Tasks

D

Dougal Fair

Hello,

I have written a vb.net program that invokes an Access2000 report in
Preview mode, so that it shows on the screen. My program then goes on
its merry way and the user can read the report and close it at his
leisure.

My problem is: when I run this on Win2000 and watch it with the Task
Manager, I see it create a task for MSACCESS.EXE for the report. But
when the user closes the report, the task does not always disappear
from the Task Manager (sometimes it does).

When it hangs around, then I can't double-click on an Acess2000 MDB
database file in Windows Explorer so as to open the database.
Apparently the existing instance of the MSACCESS.EXE task gets in the
way.

If I close the dialog from which I launched the Acess2000 report,
sometimes that causes the MSACCESS.EXE task to go away, but frequently
it does not. If I close the VB program itself, that usually kills the
MSACCESS.EXE taks, but not always. Sometimes, if I repetedly invoke
reports from my program (for different customer records), I can get
multiple MSACCESS.EXE tasks going, and even though I close the
Access2000 report windows and exit the VB program, the MSACCESS.EXE
tasks remain, and the only way I can get rid of them is to kill them
from within the Task Manager.


I thought this was because of how .NET doesn't actually release memory
even though you have closed and disposed of the objects that used the
resources, but how do I force the resources to be released?


Here is the code I use to invoke the reports:



Public Sub PreviewInvoice()

Dim ac As New Access.Application

ac.OpenCurrentDatabase(oApp.DatabaseFileName)

ac.DoCmd.OpenReport("03Invoice", Access.AcView.acViewPreview,
"qry03InvoiceQuery", "[BillingEntityID]=" & Me.ID)

ac.Visible = True
ac.DoCmd.Maximize()

ac = Nothing

End Sub



Can anybody provide me with a clue here?

TIA
 
K

Ken Tucker [MVP]

Hi,

Add this after ac= nothing .
System.Runtime.InteropServices.Marshal.ReleaseComObject(ac)

Ken
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Dougal Fair) scripsit:
I have written a vb.net program that invokes an Access2000 report in
Preview mode, so that it shows on the screen. My program then goes on
its merry way and the user can read the report and close it at his
leisure.

My problem is: when I run this on Win2000 and watch it with the Task
Manager, I see it create a task for MSACCESS.EXE for the report. But
when the user closes the report, the task does not always disappear
from the Task Manager (sometimes it does).

<http://support.microsoft.com/default.aspx?scid=kb;en-us;317109>
 
D

Dougal Fair

Hi,

Add this after ac= nothing .
System.Runtime.InteropServices.Marshal.ReleaseComObject(ac)

Ken

Thank you very much - that did the trick. Except that when I added
that line *after* the ac=nothing it complained about ac not being set
to any object. So I moved the line to just *before* the ac=nothing
statement and then it appears to work fine.

Again, thanks much - it was not at ALL obvious to me how to do that.



-----------------
Dougal Fair said:
Hello,

I have written a vb.net program that invokes an Access2000 report in
Preview mode, so that it shows on the screen. My program then goes on
its merry way and the user can read the report and close it at his
leisure.

My problem is: when I run this on Win2000 and watch it with the Task
Manager, I see it create a task for MSACCESS.EXE for the report. But
when the user closes the report, the task does not always disappear
from the Task Manager (sometimes it does).

When it hangs around, then I can't double-click on an Acess2000 MDB
database file in Windows Explorer so as to open the database.
Apparently the existing instance of the MSACCESS.EXE task gets in the
way.

If I close the dialog from which I launched the Acess2000 report,
sometimes that causes the MSACCESS.EXE task to go away, but frequently
it does not. If I close the VB program itself, that usually kills the
MSACCESS.EXE taks, but not always. Sometimes, if I repetedly invoke
reports from my program (for different customer records), I can get
multiple MSACCESS.EXE tasks going, and even though I close the
Access2000 report windows and exit the VB program, the MSACCESS.EXE
tasks remain, and the only way I can get rid of them is to kill them
from within the Task Manager.


I thought this was because of how .NET doesn't actually release memory
even though you have closed and disposed of the objects that used the
resources, but how do I force the resources to be released?


Here is the code I use to invoke the reports:



Public Sub PreviewInvoice()

Dim ac As New Access.Application

ac.OpenCurrentDatabase(oApp.DatabaseFileName)

ac.DoCmd.OpenReport("03Invoice", Access.AcView.acViewPreview,
"qry03InvoiceQuery", "[BillingEntityID]=" & Me.ID)

ac.Visible = True
ac.DoCmd.Maximize()

ac = Nothing

End Sub



Can anybody provide me with a clue here?

TIA
 
M

Mary Chipman

FWIW, you don't need the ac=nothing statement.

-- Mary
MCW Technologies
http://www.mcwtech.com

Hi,

Add this after ac= nothing .
System.Runtime.InteropServices.Marshal.ReleaseComObject(ac)

Ken

Thank you very much - that did the trick. Except that when I added
that line *after* the ac=nothing it complained about ac not being set
to any object. So I moved the line to just *before* the ac=nothing
statement and then it appears to work fine.

Again, thanks much - it was not at ALL obvious to me how to do that.



-----------------
Dougal Fair said:
Hello,

I have written a vb.net program that invokes an Access2000 report in
Preview mode, so that it shows on the screen. My program then goes on
its merry way and the user can read the report and close it at his
leisure.

My problem is: when I run this on Win2000 and watch it with the Task
Manager, I see it create a task for MSACCESS.EXE for the report. But
when the user closes the report, the task does not always disappear
from the Task Manager (sometimes it does).

When it hangs around, then I can't double-click on an Acess2000 MDB
database file in Windows Explorer so as to open the database.
Apparently the existing instance of the MSACCESS.EXE task gets in the
way.

If I close the dialog from which I launched the Acess2000 report,
sometimes that causes the MSACCESS.EXE task to go away, but frequently
it does not. If I close the VB program itself, that usually kills the
MSACCESS.EXE taks, but not always. Sometimes, if I repetedly invoke
reports from my program (for different customer records), I can get
multiple MSACCESS.EXE tasks going, and even though I close the
Access2000 report windows and exit the VB program, the MSACCESS.EXE
tasks remain, and the only way I can get rid of them is to kill them
from within the Task Manager.


I thought this was because of how .NET doesn't actually release memory
even though you have closed and disposed of the objects that used the
resources, but how do I force the resources to be released?


Here is the code I use to invoke the reports:



Public Sub PreviewInvoice()

Dim ac As New Access.Application

ac.OpenCurrentDatabase(oApp.DatabaseFileName)

ac.DoCmd.OpenReport("03Invoice", Access.AcView.acViewPreview,
"qry03InvoiceQuery", "[BillingEntityID]=" & Me.ID)

ac.Visible = True
ac.DoCmd.Maximize()

ac = Nothing

End Sub



Can anybody provide me with a clue here?

TIA
 

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