将一个实例拖放到Windows窗体应用程序的第二个实例时RemotingException [英] RemotingException when drag and drop from one instance to a second instance of Windows Forms application

查看:75
本文介绍了将一个实例拖放到Windows窗体应用程序的第二个实例时RemotingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体示例应用程序,我们用它来说明我们的外部应用程序的拖放功能。示例应用程序包含两个列表框,DragSource和DropTarget。 DragSource填充了可以将
拖放到DropTarget或我们的外部应用程序的数据。示例应用程序是使用链接到旧C ++库的Windows窗体应用程序在Visual Studio 2008中编写的。


什么有效:


1。在同一实例中的两个列表框之间拖放


2。在示例应用程序和我们的外部应用程序之间拖放


什么行不通,希望得到您的反馈:


1。在示例应用程序和示例应用程序的另一个实例之间拖放无法从MemoryStream读取数据并指示以下异常:"类型'System.Runtime.Remoting.RemotingException'的第一次机会异常'发生
in mscorlib.dll"


2。尽管DropTarget和我们的外部应用程序能够读取流并显示信息,但从DragSource拖动表示以下异常。



System.Windows.Forms.dll中出现'System.Runtime.InteropServices.COMException'类型的第一次机会异常; 第一次机会异常System.Windows.Forms.dll中出现'System.NotImplementedException'类型;  mscorlib.dll中发生'System.Runtime.Serialization.SerializationException'类型的第一次机会异常



实施:


当我从DragSource拖动一个项目时,我创建一个包含带有XML数据的MemoryStream的DataObject,并将其放到我的DropTarget中,我将MemoryStream转换为一个字节数组,并在第二个列表
框中显示信息。 我使用MemoryStream,因为这是我们的应用程序所期望的类型。 


研究,我发现了同一个问题的另一个实例,但没有解析。


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


我还发现一些信息表明这可能是一个远程安全问题,需要设置BinayrServerFormatterSinkProvider :: TypeFilterLevel = Full,但我无法访问该类
System :: Runtime :: Remoting :: Channels


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


应用程序应该是同一台机器上的简单拖放应用程序,所以我希望尽可能放弃任何远程处理。 我很感激你能提供的任何见解。

解决方案

你好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


这篇关于将一个实例拖放到Windows窗体应用程序的第二个实例时RemotingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆