G
Guest
I have been trying to use the Office PIA's to write an ASP.NEt page to:
1. Open a template workbook
2. Populate some data
3. Save the file back to the server
4. Quit Excel and free up Memory
I have been able to do all of the above steps except #4. Each time
Excel.exe persists in memory. I have already referred to Q317109 "Office
application does not quit after automation from Visual Studio .NET client"
without much luck.
I've tried stripping down the Office code to see where this hang is coming
from exactly and found the following:
WORKS: The following DID release Excel.exe:
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
ERROR: When I augment it to the following however, Excel.exe continues to
hang:
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim wkBook As Workbook = xlApp.Workbooks.Open("C:\test.xls")
xlApp.Workbooks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wkBook)
wkBook = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
If anyone could explain why this might be happening, it would be greatly
appreciated. It seems as if as soon as I get into working with a workbook,
Excel.exe is stuck in memory. Rather than a specific fix for the above, I'm
just looking to better understand the dynamics/rules here for avoiding this
problem.
Thanks in advance,
Chris Frohlich
1. Open a template workbook
2. Populate some data
3. Save the file back to the server
4. Quit Excel and free up Memory
I have been able to do all of the above steps except #4. Each time
Excel.exe persists in memory. I have already referred to Q317109 "Office
application does not quit after automation from Visual Studio .NET client"
without much luck.
I've tried stripping down the Office code to see where this hang is coming
from exactly and found the following:
WORKS: The following DID release Excel.exe:
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
ERROR: When I augment it to the following however, Excel.exe continues to
hang:
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim wkBook As Workbook = xlApp.Workbooks.Open("C:\test.xls")
xlApp.Workbooks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wkBook)
wkBook = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
If anyone could explain why this might be happening, it would be greatly
appreciated. It seems as if as soon as I get into working with a workbook,
Excel.exe is stuck in memory. Rather than a specific fix for the above, I'm
just looking to better understand the dynamics/rules here for avoiding this
problem.
Thanks in advance,
Chris Frohlich