Sometime ago, i downloaded a sample of command and mouse objects named PickDrawingView, written in VB.Net provided in this forum.
I tried out and it seems to work fine, although when it reaches the release of the objects in the m_command_terminate event if i catch a exception i get the following:
message "Exception as been thrown by the target of an invocation"
innerexception message "COM object that is been separated from its underlying RCW cannot be used"
I put some breakpoints and it seems to get the error in the m_mouse=nothing statement.
I'm using sev20.00.10.03 and VB.net 2005,
My questions are:
Why is this happening?
It's a problem not to set the objects to nothing after releasing them?
If it's a problem, what can i do to fix this?
Thanks for sharing your knowledge in this forum.
VB6 could work with COM objects natively. VB.NET interacts with COM objects via Runtime Callable Wrapper (RCW). Consequently, working with COM is much more difficult in .NET. COM used deterministic release of objects whereas .NET uses non-deterministic Garbage Collection (GC).
So in VB6, you could Set objCOM = Nothing and the object was released. In .NET, when you Set objCOM = Nothing, you are simply marking the object "eligible" for collection and you don't know when it's going to be released. We do have Marshal.ReleaseComObject() but again, it does not "truely" release the COM reference.
In your case, your object is somehow being freed and collected before you're done. I'd really need to see your entire project to determine what's going on.
Posted by: Jason Newell Post date: 1/31/2009 3:47:47 PM