How do I extract my data from a Drag & Drop ComObject?



I’m trying to drag & drop listview items between two instances of my app. The
actual data that’s passed in DoDragDrop is an arraylist that’s been
serialized to a memorystream. The contents of the arraylist are objects of a
simple, serializable custom class that allows the recipient listview to
reconstruct the dragged listitems. (the contents of the arraylist actually
don’t matter…they can be simple integers and the issues in this post remain
the same)

When I’m dragging & dropping within an instance of my app, e.Data from the
DragDrop event is a DataObject and I can extract my memorystream, deserialize
it, and I’m good. However, when I drag & drop to another instance of my
application, e.Data is a System.__ComObject. Attempting to extract my data
with the normal e.Data.GetData method results in a memorystream that’s,
according to the Locals window, a
System.Runtime.Remoting.Proxies.__TransparentProxy, which is beyond the scope
of my VB knowledge. Regardless, it doesn’t deserialize, and now I’m stuck.

So could someone kindly explain what I need to do to the __ComObject to get
my memorystream out? Here’s my code:

If e.Data.GetDataPresent("System.IO.MemoryStream") Then
Dim Formatter As New BinaryFormatter
Dim Stream As New System.IO.MemoryStream
Dim DropList As New ArrayList

Stream = e.Data.GetData("System.IO.MemoryStream")
Stream.Position = 0
DropList = Formatter.Deserialize(Stream)

Any help would be appreciated.



Hi Neil,

I am having the exact same problem and was disappointed to see that
nobody replied... Did you find a solution that you could share?


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question