简体   繁体   English

.Net远程处理-委托的序列化

[英].Net Remoting - Serialisation of Delegates

I have written a custom remoting formatter sink for an established application. 我为已建立的应用程序编写了一个自定义的远程格式化程序接收器。 The formatter appears to work for most cases until I try to use it to call a remote method to which I pass a call-back to a CAO. 格式化程序似乎在大多数情况下都可以使用,直到我尝试使用它来调用将回调传递给CAO的远程方法为止。 At this point I get a SerializationException indicating that I am trying to serialise the CAO, which is obviously not what I want to do. 此时,我得到一个SerializationException,表明我正在尝试序列化CAO,这显然不是我想要执行的操作。 The CAO inherits from MBRO and object lifetimes do not come into play at this stage. CAO继承自MBRO,并且对象生存期在此阶段不起作用。

Does anyone know how I can serialise the incoming IMessage in my formatter in such a way as to preserve the reference to the CAO? 有谁知道我该如何在格式化程序中序列化传入的IMessage,以保留对CAO的引用? I assume that I need to walk the object graph, converting the CAO to an ObjRef which can then be serialised but my problem is more fundamental as I do not have a concrete 'Message' to serialise, only an IMessage. 我假设我需要遍历对象图,将CAO转换为ObjRef,然后可以对其进行序列化,但是我的问题更为根本,因为我没有具体的“消息”要序列化,而只有IMessage。 I would prefer not to use reflection. 我宁愿不使用反射。

I am aware of WCF, but do not wish to migrate to it at this stage as the application is quite large. 我知道WCF,但是由于应用程序很大,因此不希望在此阶段迁移到WCF。

There's an excellent article on Codeproject that may provide you with the answers you are looking for. Codeproject上有一篇很棒的文章,可能会为您提供所需的答案 Implementing events/delegates in remoting is very tricky and the workaround is also tricky to implement. 在远程处理中实现事件/代理非常棘手,解决方法也很难实现。 The best site to read up on this is this dude, Ingo Rammer who wrote and authored an excellent book on remoting. 最好的阅读网站的人是Ingo Rammer ,他撰写并撰写了有关远程处理的出色著作。 I have used GenuineChannels in the past to circumvent the usage of event handling limitation found in the standard .NET remoting and it does work. 过去,我曾使用GenuineChannels来规避在标准.NET远程处理中发现的事件处理限制的用法,并且它确实起作用。 However GenuineChannels seems to be in trouble already... 但是, 正版频道似乎已经陷入麻烦...

Hope this helps, Best regards, Tom. 希望这对您有所帮助,汤姆,谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM