c# - MarshalByValue 对象有什么意义?

标签 c# .net clr

我们知道 MarshalByRef 允许我们在不同的 AppDomain 中创建一个对象并使用 Proxy 对象来访问它。并且该对象的行为处于它实际所在的 AppDomain 的不同上下文中。嗯,这在隔离和安全方面听起来相当合理。

但是为什么还有MarshalByValue呢? MarshalByValue 只会导致一个新的反序列化对象,它是不同 AppDomain 中对象的精确副本。如果我们需要那个对象,为什么不直接在当前的 AppDomain 中创建它呢?为什么要先在不同的 AppDomain 中创建它,然后通过 MarshaoByValue 取回它?

非常感谢。

最佳答案

取自MSDN :-

When considering MarshalByRefObject objects, all calls on the object are round trips to the server. Sometimes, an object that is marshaled by value rather than by reference is required, so that subsequent calls to the marshaled object will be local rather than remote. In DCOM, implementing marshal-by-value objects required substantial work. With .NET remoting, all that is required is that the object being returned by value is serializable.

关于c# - MarshalByValue 对象有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2895283/

相关文章:

javascript - 关于从 ASP .NET 用户控件迁移到 .NET 3.5 母版页技术的问题

c# - C++/CLI clr :safe for C# COM Interop 中的包装器 C++

c# - 由于 CLR.dll Windows 应用程序崩溃 - Windows 2008 R2 Server

c# - UserControl 在放置在窗体上时膨胀?

c# - EF 的 DbContext 的单例范围

c# - 移动没有标题栏的表格

c# - 如何覆盖 ScintillaNet 中的 PASTE 操作?

.net - 自动将 CLR 数据库项目部署到数据库

c# - 将 .Net 实体数据模型与 SQLite 结合使用

c# - xaml d :DataContext giving "Access is denied" error