S
Suzanne Barclay
I've a problem with a VB .NET web service.
After writing code (see below) I run the webservice &
invoke the method - it works but when I look at Task
Manager, EXCEL.EXE still hangs around!!! (ie. each time
I invoke test, a new instance of excel.exe appears)
NOTE: 1. Same code in a console app works fine.
2. If I recompile web service, all instances of
excel.exe disappear from TaskManager
Steps to recreate problem:
1) Create new web service and add a reference to Excel
type library
2) Create single web method as follows:
<WebMethod()> Public Function CreateExcelAndQuit() As
String
Dim oExcel As Excel.Application
Dim oExcelSht As Excel.Worksheet
Try
oExcel = New Excel.Application
oExcel.Workbooks.Add()
oExcelSht = oExcel.ActiveSheet()
oExcelSht.Range("A1").FormulaR1C1 = "test"
oExcel.DisplayAlerts = False
oExcelSht.SaveAs("c:\workdocs\testExcel.xls")
oExcel.Quit()
Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
Catch ex As Exception
Return "Error : " & ex.Message
End Try
End Function
After writing code (see below) I run the webservice &
invoke the method - it works but when I look at Task
Manager, EXCEL.EXE still hangs around!!! (ie. each time
I invoke test, a new instance of excel.exe appears)
NOTE: 1. Same code in a console app works fine.
2. If I recompile web service, all instances of
excel.exe disappear from TaskManager
Steps to recreate problem:
1) Create new web service and add a reference to Excel
type library
2) Create single web method as follows:
<WebMethod()> Public Function CreateExcelAndQuit() As
String
Dim oExcel As Excel.Application
Dim oExcelSht As Excel.Worksheet
Try
oExcel = New Excel.Application
oExcel.Workbooks.Add()
oExcelSht = oExcel.ActiveSheet()
oExcelSht.Range("A1").FormulaR1C1 = "test"
oExcel.DisplayAlerts = False
oExcelSht.SaveAs("c:\workdocs\testExcel.xls")
oExcel.Quit()
Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
Catch ex As Exception
Return "Error : " & ex.Message
End Try
End Function