关于 .NET 远程处理和序列化的问题
我有一个接口(将其命名为 OuterInt)和一个实现它的类(OuterClass)。接口 OuterInt 由其他接口(InnerInt1、InnerInt2 等)组成,并且有一些类(InnerClass1、InnerClass2 等)实现这些内部接口。 OuterClass 通过 .NET 远程处理由应用程序的服务器端公开 (RemotingServices.Marshal(_OuterClass, "myOuterInt");) 我的问题是内部类是否会在远程处理过程中被序列化,应用程序的客户端是否应该知道这些类(例如,引用这些类的程序集)?我希望我明确地描述了我的问题,如果没有 - 请在评论中询问我。
I have a interface (let name it OuterInt) and a class (OuterClass) that implemented It. Interface OuterInt consists of the other intefaces (InnerInt1, InnerInt2 and etc.) And there are some classes (InnerClass1, InnerClass2 and etc.) that implement these inner interfaces. OuterClass is exposed by server-side of application by .NET remoting (RemotingServices.Marshal(_OuterClass, "myOuterInt");)
My question is will inner classes be serialized in the process of remoting or not and should client-side of application knows about those classes (for example to have reference of assembly with these classes)? I hope that I described my question explicitly, if not - ask me in comments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
远程处理(正如 Oded 所说,几乎已被弃用)创建一个到对象的远程钩子;不是API(接口)。因此,确实需要在两端具有相同的 dll(包含被远程的具体类型)。是序列化还是代理取决于它是否继承自
MarshalByRefObject
。但通常情况下:如果它位于一端的对象图中,那么它需要在另一端可创建。如果可能的话,在我看来,实际上更喜欢任何其他实现而不是远程处理。
Remoting (which is, as Oded notes, pretty much deprecated) creates a remote hook to the object; not the API (the interface). As such, it will indeed be necessary to have the same dll (containing the concrete type being remoted) at both ends. Whether it is serialized vs proxied depends on whether it inherits from
MarshalByRefObject
. But typically: if it is in the object graph at one end, then it needs to be creatable at the other.If possible, prefer virtually any other implementation to remoting, IMO.