Avatar of EdwardAF
Flag for United States of America asked on

Disconnected Context Using Excel Automation

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?
Visual Basic.NETMicrosoft Excel

Avatar of undefined
Last Comment

8/22/2022 - Mon
Nasir Razzaq

Looks like timeout to me.

How do we stop the timeout?
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I have tried running the app completey hands-off - not touching Excel or even the mouse.  It still throws this error at about the same time as before.  Any other ideas?
Your help has saved me hundreds of hours of internet surfing.
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

This link gave me some other places to look but did not in and of itself resolve the issue.