troubleshooting Question

Disconnected Context Using Excel Automation

Avatar of EdwardAF
EdwardAFFlag for United States of America asked on
Microsoft ExcelVisual Basic.NET
6 Comments2 Solutions2596 ViewsLast Modified:
I recently finished writing a routine to apply processing to an Excel file through VB.NET using the automation API.  The code works fine, and it is called repeatedly for about 60 work items.  In other words, about 60 reports are being rendered from rdlc to Excel, and then those 60 files are processed one by one using this routine.

At about the 60% or 70% mark during processing, which is usually between 15 and 20 minutes into the process, the following exception is thrown:

DisconnectedContext was detected
Message: Context 0x198388' is disconnected.  Releasing the interfaces from the current context (context 0x1984f8).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.

I am not a COM expert, and it sounds like this is a COM error.  I am only using COM to the extent needed to make use of Excel automation.

What is this exception, and how can I keep this from happening until all of the processing is complete?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros