Corey Scheich
asked on
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"
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"
Make sure that the COM object is defined at class level and not in a subroutine or function that will go out of scope.
ASKER
All the ones that need to be accessed later are.
Then I don't know what to tell you, sorry.
ASKER
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
Lookup
Walkthrough: Supporting COM Interop by Displaying Windows Forms on a Shared Thread
in the .net framework 2.0 SDK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.