LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.office.developer.com.add_ins,microsoft.public.vsnet.vstools.office,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel remains running due to held references

We are building a COM addin using C# and .NET 1.1, targeting Office XP
and Office 2003. We are not using VSTO.
The purpose of the COM addin is to do some custom work when certain
XLS-documents are loaded (such as showing a custom toolbar, etc)
The COM addin works fine when Excel is running stand-alone. But when
Excel is running inside Internet Explorer, Excel remains running after
IE is closed.
I guess this is due to the fact that we hold references to Excel from
within the addin. The problem is that I don't understand how I can
avoid this, if the addin should work as expected.
There's a catch-22 he In order for Excel to unload when IE closes,
all references to it must be released.
However, for my addin to release the references,
IDTExtensibility2.OnDisconnection must be called, which doesn't happen
until Excel closes.

Any ideas:

Here's the pattern we use (simplified):

public void OnConnection(object application, ...) // Implementation of
IDTExtensibility2
{
applicationObject = (Excel.Application)application; // Save the
app-object for later
}

public void OnStartupComplete(ref System.Array custom)
{
applicationObject.WorkbookOpen += new
Microsoft.Office.Interop.Excel.AppEvents_WorkbookO penEventHandler(applicationObject_WorkbookOpen);
}

public void OnDisconnection(...)
{
applicationObject = null;

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}

public void OnBeginShutdown(ref System.Array custom)
{
TearDownUI();

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}

private void
applicationObject_WorkbookOpen(Microsoft.Office.In terop.Excel.Workbook
wb)
{
SetUPUI();
}


Thanks!
/Fredrik

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I held the space bar down for too long in EXCEL. Grant Excel Discussion (Misc queries) 1 October 9th 06 11:04 AM
How do I hyperlink from Excel to a document held in Lotus Notes? Andy Lloyd Excel Discussion (Misc queries) 0 May 4th 05 10:46 AM
Working with Dates: Calculating A Running Total for Days Held Mcasteel[_48_] Excel Programming 1 November 18th 04 07:09 PM
Working with Dates: Calculating A Running Total for Days Held Mcasteel[_47_] Excel Programming 2 November 17th 04 10:57 PM
Excel process remains running Josh[_5_] Excel Programming 2 September 11th 03 04:22 PM


All times are GMT +1. The time now is 08:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"