We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to keep an object alive

Corey Scheich
on
Medium Priority
505 Views
Last Modified: 2012-05-05
I am receiving the following MDA error

Context 0x1935b8' is disconnected.  Releasing the interfaces from the current context (context 0x1937e0).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.

How do I ensure that ensure that my wrappers and COM objects "Stay Alive"
Comment
Watch Question

Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Make sure that the COM object is defined at class level and not in a subroutine or function that will go out of scope.
Corey ScheichDeveloper

Author

Commented:
All the ones that need to be accessed later are.
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Then I don't know what to tell you, sorry.
Corey ScheichDeveloper

Author

Commented:
The error seems to have had to do more with the form that was running wasn't message pumping.  I created it in it's own STA thread using the following example.  After implementing this I didn't receive this MDA error any more.

Lookup

Walkthrough: Supporting COM Interop by Displaying Windows Forms on a Shared Thread

in the .net framework 2.0 SDK
Commented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.