Windows Service keeps process open.

G

Guest

I have a Windows Service that watches a directory using the FileSystemWatcher. When an Excel spreadsheet gets added to that directory, the Windows Service calls a routine that opens the Excel spreadsheet and does some processing (on a seperate thread). After processing is done on the spreadsheet, it is closed and the reference is set to Nothing. However, if you go to the Task Manager, the Excel process is still there. Each time the Service processes a new Excel spreadsheet, a new Excel process is in the Task Manager. Even after stopping the Service, the Excel processes are still in the Task Manager

How do you get the Excel processes in the Task Manager to go away? Any help is appreciated. Thanks.
 
G

Guest

The code quits the Excel application and sets the reference to Nothing. What else should I need to do? For example

Dim oXL as Excel.Applicatio
Dim oWB as Excel.WorkBoo
'Do some processing stuf
'Before the routine exits, the below is don
oWB = Nothin
oXL.Quit(
oXL = Nothin

I thought that would be enough, but the Excel Processes are still in the Task Manager.
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?Z2I=?= said:
I have a Windows Service that watches a directory using the
FileSystemWatcher. When an Excel spreadsheet gets added to that
directory, the Windows Service calls a routine that opens the Excel
spreadsheet and does some processing (on a seperate thread).

Don't do Office automation in a service, that's not recommended:

<URL:http://support.microsoft.com/?kbid=257757>
 
C

Chris Dunaway

The code quits the Excel application and sets the reference to Nothing. What else should I need to do? For example:

Dim oXL as Excel.Application
Dim oWB as Excel.WorkBook
'Do some processing stuff
'Before the routine exits, the below is done
oWB = Nothing
oXL.Quit()
oXL = Nothing

I thought that would be enough, but the Excel Processes are still in the Task Manager.

I notice that the code above does not close the workbook. Is that
necessary?

I'm haven't done much office automation, but have you tried calling the
ReleaseComObject method?

Marshal.ReleaseComObject(oXL)

Just some thoughts
 

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