• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

How to keep an object alive

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"
0
Corey Scheich
Asked:
Corey Scheich
  • 2
  • 2
1 Solution
 
Fernando SotoCommented:
Make sure that the COM object is defined at class level and not in a subroutine or function that will go out of scope.
0
 
Corey ScheichDeveloperAuthor Commented:
All the ones that need to be accessed later are.
0
 
Fernando SotoCommented:
Then I don't know what to tell you, sorry.
0
 
Corey ScheichDeveloperAuthor 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
0
 
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now