Strange Drag and Drop problem

Strange Drag and Drop problem

Old forum URL: forums.lhotka.net/forums/t/651.aspx


razorkai posted on Tuesday, July 18, 2006

Hi guys.

I have a custom TreeNode that stores a reference to a Csla Business Object in a property.  I wanted to support drag and drop of this TreeNode and its related business object to another application.  First off I tried drag and drop within the same application, and that worked fine.  Then I tried drag and drop to another application and got the Exception "This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server".

This is the code I am using (tvBusinessObjects is a TreeView)

private void tvBusinessObjects_MouseMove(object sender, MouseEventArgs e)
{
      
if (e.Button == MouseButtons.Left && tvBusinessObjects.SelectedNode != null)
      
{
         
DoDragDrop(tvBusinessObjects.SelectedNode, DragDropEffects.Move);
      }
}

private void tvBusinessObjects_DragDrop(object sender, DragEventArgs e)
{
   
//Check the type of the data is correct
   
if (e.Data.GetDataPresent(typeof(BusinessObjectTreeNode)))
   {
      BusinessObjectTreeNode tn = (BusinessObjectTreeNode)e.Data.GetData(typeof(BusinessObjectTreeNode));
      ProcessDraggedBizObject(tn);
   }
}

private void ProcessDraggedBizObject(BusinessObjectTreeNode tn)
{
   BusinessObject bo = tn.BusinessObject;   //Exception raised here!
   //Do some more stuff with the BO
}

If I look at the value of the tn variable in the DragDrop event it is listed as System.Runtime.Remoting.Proxies__TransparentProxy rather than BusinessObjectTreeNode as expected.  When dragging locally it seems to be the correct type.  What on earth do I need to do to get this to work correctly?  Hope somone can help!

TIA

razorkai replied on Tuesday, July 18, 2006

Interesting, I can replicate this without using the Csla at all i.e. with a standard TreeView.  Still struggling to fix it though!

razorkai replied on Tuesday, July 18, 2006

Figured it out.  TreeNode is not Serializable!  Can get around this by passing the actual biz object rather than the TreeNode.

Copyright (c) Marimer LLC