且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将一个实例拖放到Windows窗体应用程序的第二个实例时RemotingException

更新时间:2023-11-22 17:04:52

你好JVR,


 


在做的时候在Winform中拖放操作,我们需要调用DoDragDrop方法并将DataObject传递给该方法。 DataObject用于保存拖动数据。如何使用MemoryStream实现
的逻辑?您能否发布一些当前方法的代码?


 


此致


Kira Qian


MSDN Subscriber Support 在论坛


如果您有任何反馈意见我们的支持,请联系
msdnmg@microsoft.com

I have a Windows Forms sample app that we use to illustrate drag and drop functionality with our external application. The sample app contains two list boxes, a DragSource and a DropTarget. The DragSource is populated with data that can be dragged and dropped to the DropTarget, or to our external application. The sample app is written in Visual Studio 2008 using a Windows Forms Application that links to a legacy C++ library.

What works:

1. Dragging and dropping between the two listboxes in the same instance

2. Dragging and dropping between the sample app and our external application

What doesn't work and hope to get your feedback on:

1. Dragging and dropping between the sample app and another instance of the sample app fails to read data from the MemoryStream and indicates the following exception: "A first chance exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll"

2. Dragging from the DragSource indicates the following exceptions although the DropTarget and our external application are able to read the stream and display the information.

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll; A first chance exception of type 'System.NotImplementedException' occurred in System.Windows.Forms.dll;  A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

Implementation:

When I drag an item from the DragSource, I create a DataObject containing a MemoryStream with XML data, and drop it to my DropTarget where I convert the MemoryStream into a Byte Array, and display the information in the second list box.  I use a MemoryStream because this is the type that our application expects. 

Researching, i found another instance of the same exact issue, but no resolution.

http://www.canbal.com/view.php?sessionid=nrRIYiKriXF4w7Y6issfSqr5P3Eg7VXXwafYxmT3csA%3D

I also found some information that indicate this may be a remoting security issue which requires setting the BinayrServerFormatterSinkProvider::TypeFilterLevel = Full, but I'm not able to access the class from System::Runtime::Remoting::Channels

http://msdn.microsoft.com/en-us/library/5dxse167(v=VS.90).aspx

The app is supposed to be a simple drag and drop application on the same machine, so I hope to foregoes any remoting if possible.  I appreciate any insight you can provide.

Hi JVR,

 

When doing drag and drop operation in Winform, we need to call DoDragDrop method and pass DataObject to the method. The DataObject is used to hold dragging data. How do you implement the logical by using MemoryStream? Could you please post some code of your current approach?

 

Sincerely,

Kira Qian

MSDN Subscriber Support in Forum

If you have any feedback on our support, please contact msdnmg@microsoft.com