P
patstix
My C# add-in implements IDTExtensibility2. As long as I don't sync my
add-in to any Excel events, it works perfectly and the Excel instance
is removed when Excel is shut down.
However, my add-in must listen to some Excel events. I hook them up
during OnConnection, like so (using any of the Excel Workbook events
gives the same problem):
applicationObject.WorkbookOpen += new
Microsoft.Office.Interop.Excel.AppEvents_WorkbookOpenEventHandler(applicationObject_WorkbookOpen);
Once I add this line of code, the Excel instance sticks around, even
after Excel is terminated and released. Removing the delegate from
the event (and releaseing the COM reference) in the OnDisconnection
method does not help.
Using .Net 2.0 and the issue exists with at least Office XP and 2003.
The code used to test the creation and release of the Excel instance
is here:
Sub Test()
Set oXL = CreateObject("Excel.Application")
Set WBs = oXL.Workbooks
Set Wkbk = WBs.Add
Set Wkbk = Nothing
Set WBs = Nothing
oXL.Quit
Set oXL = Nothing
End Sub
add-in to any Excel events, it works perfectly and the Excel instance
is removed when Excel is shut down.
However, my add-in must listen to some Excel events. I hook them up
during OnConnection, like so (using any of the Excel Workbook events
gives the same problem):
applicationObject.WorkbookOpen += new
Microsoft.Office.Interop.Excel.AppEvents_WorkbookOpenEventHandler(applicationObject_WorkbookOpen);
Once I add this line of code, the Excel instance sticks around, even
after Excel is terminated and released. Removing the delegate from
the event (and releaseing the COM reference) in the OnDisconnection
method does not help.
Using .Net 2.0 and the issue exists with at least Office XP and 2003.
The code used to test the creation and release of the Excel instance
is here:
Sub Test()
Set oXL = CreateObject("Excel.Application")
Set WBs = oXL.Workbooks
Set Wkbk = WBs.Add
Set Wkbk = Nothing
Set WBs = Nothing
oXL.Quit
Set oXL = Nothing
End Sub