Note that there are some explanatory texts on larger screens.

plurals
  1. POCross-Process Drag and Drop of custom object type in WinForms C#
    primarykey
    data
    text
    <p><a href="https://stackoverflow.com/questions/1213074/winforms-interop-drag-drop-from-winforms-wpf">This question</a> is close to what I'm interested in, but not quite.</p> <p>I have a .NET WinForms application written in C#. I have a <code>ListView</code> control which displays an array of C# objects. I've hooked it up so that you can drag/drop these listview items to a different form in the same application, and it properly passes the array of objects (type <code>Session</code>) to the drop handler for that other form.</p> <p>However, I now want to support cross-process drag/drop where I run multiple instances of my application. This <em>appears</em> that it's going to work (e.g. <code>GetDataPresent</code> succeeds), but ultimately throws an exception when I actually try to retrieve the data-- cannot cast <code>object[]</code> to <code>Session[]</code>.</p> <pre><code>if (e.Data.GetDataPresent("Fiddler.Session[]")) { Session[] oDroppedSessions; try { oDroppedSessions = (Session[])e.Data.GetData("Fiddler.Session[]"); } catch (Exception eX) { // reaches here } } </code></pre> <p><em>Anyone know if I <strong>must</strong> implement <code>ISerializable</code> for my objects in order to make this work? Ordinarily, I'd simply try it, but implementing <code>ISerializable</code> for this class would be quite non-trivial, and I'm worried that there may be weird side-effects of doing so.</em></p> <hr> <p><strong>UPDATE</strong>: Implementing <code>ISerializable</code> doesn't help-- the method is never called. Similarly, adding the <code>Serializable</code> attribute to the class has no impact at all. Any other ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload