Hi
My vb.net app uses Excel 97 (MSO97.DLL) through com interop as normal. The problem is when it comes to releasing the reference.
Here is the sequence for instantiating excel
Dim xlApp as Excel.Application
xlApp = CType(CreateObject("Excel.Application"
, Excel.Application)
(I always require a new instance so as not to interfere with what the user is doing)
Here is the sequence for the destruction
xlApp.DisplayAlerts = False
xlApp.Workbooks.Close()
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
GC.Collect()
this next line fires a doctor watson - excel com interop problem.
GC.WaitForPendingFinalizers()
I know that the bit about the GC is not a good idea, but the Dr Watson error occurs without the Marshal.Release, or the two GC lines anyway. I simply put these in to nail it down to one line of code, and it is the WaitForPendingFinalizers which does it.
PS The Dr Watson message is a normal one
excel.exe - Application Error
The instruction at "0x30032ff9" referenced memory at "0x65177f98". The memory could not be "read".
Has anyone else had similar problems?
My vb.net app uses Excel 97 (MSO97.DLL) through com interop as normal. The problem is when it comes to releasing the reference.
Here is the sequence for instantiating excel
Dim xlApp as Excel.Application
xlApp = CType(CreateObject("Excel.Application"
(I always require a new instance so as not to interfere with what the user is doing)
Here is the sequence for the destruction
xlApp.DisplayAlerts = False
xlApp.Workbooks.Close()
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
GC.Collect()
this next line fires a doctor watson - excel com interop problem.
GC.WaitForPendingFinalizers()
I know that the bit about the GC is not a good idea, but the Dr Watson error occurs without the Marshal.Release, or the two GC lines anyway. I simply put these in to nail it down to one line of code, and it is the WaitForPendingFinalizers which does it.
PS The Dr Watson message is a normal one
excel.exe - Application Error
The instruction at "0x30032ff9" referenced memory at "0x65177f98". The memory could not be "read".
Has anyone else had similar problems?