Drag&Drop between 2 different .NET Programs

  • Thread starter Thread starter Peter Wagner
  • Start date Start date
P

Peter Wagner

Hi

There are 2 different .NET Programs A und B.
I'll drag a TreeNode from a TreeView in A into a ListView in B.
In B I'll extract values from the dropped TreeNode.
Unfortunately I don't know how to extract the values. :-(

Code in B
--------------
private void ListView_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
:
:

:
if( e.Data.GetDataPresent( "Blabla.Node" ) ) // Blabla.Node is a
TreeNode derived Class
{
TreeNode DraggedNode =(TreeNode) e.Data.GetData( "Blabla.Node" );
// Up to above line works the drop. Debugging this code, DraggedNode
// contains the value
'System.Runtime.Remoting.Proxies.__TransparentProxy'
// I don't no how I should work with Proxies. :-(
// How can I extract the values in DraggedNode?
:
:
}
}

TIA
p
 
Peter,

You shouldn't have to do anything special. If the line with the cast
works and the DraggedNode is populated, then you should be able to access
the properties just like anything else.

However, you might want to consider using some other kind of data
container besides a tree node, as the tree node is part of a visul
component, and transporting those kinds of things across app-domains can
have a bad effect.

Hope this helps.
 
Nicholas said:

Nicholas,

Thank you for your quick answer.
You shouldn't have to do anything special. If the line with the
cast works and the DraggedNode is populated,

'Works' was not the whole truth.
I should say, the Debugger doesn't jump out till this line.
The Debugger shows for DraggedNode in the QuickWatch dialog:
DraggedNode {System.Runtime.Remoting.Proxies.__TransparentProxy}
+[System.Runtime.Remoting.Proxies.__TransparentProxy]
{System.Runtime.Remoting.Proxies.__TransparentProxy}
+System.MarshalByRefObject
{System.Runtime.Remoting.Proxies.__TransparentProxy}
-__identity
-[System.Runtime.Remoting.Proxies.RemotingProxy]
{System.Runtime.Remoting.Proxies.RemotingProxy}
:
:
:
:
TypeName "System.Windows.Forms.TreeNode"
BackColor <error: cannot evaluate field of a proxy object>
: "
: "
(List of properties)
: "
: "
: "
then you should be able
to access the properties just like anything else.

Unfortunately not.
Look the above-mentioned values. :-(
However, you might want to consider using some other kind of data
container besides a tree node,

But _it's_ a TreeNode.
as the tree node is part of a visul
component, and transporting those kinds of things across app-domains
can have a bad effect.

But TreeNode is derived from MarshalByRefObject.
The help says 'MarshalByRefObject is the base class for objects that
communicate across application domain boundaries by exchanging messages
using a proxy.'

There's no solution using Remoting, Proxies?
Hope this helps.

Yes and no.
It seems drag-dropping TreeNodes is impossible an so there's no solution.
:-(

p
 
Peter,

Using remoting/proxies in this case is overkill, as it seems you just
want to drop a snippet of data into another application. This snippet
doesn't have any affinity to the app-domain it came from (like a window
handle, or something of that nature), so you should make it a serializable
instance and then transport that across to your other program. It is the
MarshalByRefObject base class that is causing the problem.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Peter Wagner said:
Nicholas said:

Nicholas,

Thank you for your quick answer.
You shouldn't have to do anything special. If the line with the
cast works and the DraggedNode is populated,

'Works' was not the whole truth.
I should say, the Debugger doesn't jump out till this line.
The Debugger shows for DraggedNode in the QuickWatch dialog:
DraggedNode {System.Runtime.Remoting.Proxies.__TransparentProxy}
+[System.Runtime.Remoting.Proxies.__TransparentProxy]
{System.Runtime.Remoting.Proxies.__TransparentProxy}
+System.MarshalByRefObject
{System.Runtime.Remoting.Proxies.__TransparentProxy}
-__identity
-[System.Runtime.Remoting.Proxies.RemotingProxy]
{System.Runtime.Remoting.Proxies.RemotingProxy}
:
:
:
:
TypeName "System.Windows.Forms.TreeNode"
BackColor <error: cannot evaluate field of a proxy object>
: "
: "
(List of properties)
: "
: "
: "
then you should be able
to access the properties just like anything else.

Unfortunately not.
Look the above-mentioned values. :-(
However, you might want to consider using some other kind of data
container besides a tree node,

But _it's_ a TreeNode.
as the tree node is part of a visul
component, and transporting those kinds of things across app-domains
can have a bad effect.

But TreeNode is derived from MarshalByRefObject.
The help says 'MarshalByRefObject is the base class for objects that
communicate across application domain boundaries by exchanging messages
using a proxy.'

There's no solution using Remoting, Proxies?
Hope this helps.

Yes and no.
It seems drag-dropping TreeNodes is impossible an so there's no solution.
:-(

p
 
Nicholas said:

Nicholas,

Thanks for your help.
Using remoting/proxies in this case is overkill, as it seems you
just want to drop a snippet of data into another application. This
snippet doesn't have any affinity to the app-domain it came from
(like a window handle, or something of that nature), so you should
make it a serializable instance and then transport that across to
your other program.

What do you mean?
Make the class Blabla.Node [Serializable]?
How to transport? Not by Drag&Drop?
It is the MarshalByRefObject base class that is
causing the problem.

There's no solution?

p
 
Back
Top