是MarshalByRefObject的特殊? [英] Is MarshalByRefObject special?
问题描述
.NET有一个名为远程处理,您可以在单独的应用程序域,甚至在物理机之间传递物体周围的事情。我不完全理解魔术是如何完成的,因此这个问题。
.NET has a thing called remoting where you can pass objects around between separate appdomains or even physical machines. I don't fully understand how the magic is done, hence this question.
在远程处理有传递对象围绕两个基地的方式 - 他们要么可以序列化(转换成一串字节和重建的另一端),也可以从<一个继承href="http://msdn.microsoft.com/en-us/library/system.marshalbyrefobject.aspx">MarshalByRefObject,在这种情况下,.NET使得一些透明代理和所有方法调用被转发回原始实例
In remoting there are two base ways of passing objects around - either they can be serialized (converted to a bunch of bytes and the rebuilt at the other end) or they can inherit from MarshalByRefObject, in which case .NET makes some transparent proxies and all method calls are forwarded back to the original instance.
这是pretty的清凉功效神奇。而且我不喜欢魔法编程。纵观 MarshalByRefObject的
与反射我看不到任何会使其有别于任何其他典型的对象。甚至没有一个奇怪的内在属性或任何东西。因此,如何在全透明代理的东西组织起来?我能做出这样一个机制,我自己?我可以做一个替代 MyMarshalByRefObject
这将不会从 MarshalByRefObject的
继承,但仍然做得一样?或者是 MarshalByRefObject的
由.NET发动机本身和整个远程壮举非duplicatable由凡人?接受一些特殊待遇
This is pretty cool and works like magic. And I don't like magic in programming. Looking at the MarshalByRefObject
with the Reflector I don't see anything that would set it apart from any other typical object. Not even a weird internal attribute or anything. So how is the whole transparent proxy thing organized? Can I make such a mechanism myself? Can I make an alternate MyMarshalByRefObject
which would not inherit from MarshalByRefObject
but would still act the same? Or is MarshalByRefObject
receiving some special treatment by the .NET engine itself and the whole remoting feat is non-duplicatable by mere mortals?
推荐答案
魔术似乎是在一个特殊的 TransparentProxy
级 - .NET运行库处理它在一个特殊的方法。
The magic seems to be in a special TransparentProxy
class - the .NET Runtime handles it in a special way.
- 如果您想使用它,请参阅约RealProxy 的文章 [链接现在看起来破:-( 2011-10-14] 的。
- 如果您想了解更多关于神奇,见文章在TransparentProxy实施。
- 有关的基本概况,请尝试 MSDN文章远程处理:技术概述。
- If you want to use it, see an article about RealProxy[link looks broken now :-( 2011-10-14].
- If you want to read more about the "magic", see an article on TransparentProxy implementation.
- For a basic overview, try the MSDN article "Remoting: A Technical Overview".
我觉得 MarshalByRefObject的
可能包含一些额外的内部信息,这可以帮助这一机制,但我没有看过太多到这一点。
I think that MarshalByRefObject
may contain some additional internal information which can be helpful for this mechanism, but I haven't looked much into that.
这篇关于是MarshalByRefObject的特殊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!