简体   繁体   English

在不进行序列化/反序列化(C#)的情况下将“非序列化”对象传递到另一个应用程序域

[英]Pass a “non-serialized” object to another appdomain without Serilization/Deserialization (C#)

What is the best way for passing a "non-serialized" object to another appdomain without Serilization/Deserialization ? 在不进行序列化/反序列化的情况下 ,将“非序列化”对象传递到另一个应用程序域的最佳方法是什么?

More detail: I'm going to invoke a function (from external assembly/plugin) in new appdomain and pass the result to main appdomain (main program). 更详细:我将在新的appdomain中调用一个函数(从外部程序集/插件),并将结果传递给主appdomain(主程序)。 but (unfortunately) the result type is not serializable and therefore i faced to SerializationException 但是(不幸的是)结果类型不可序列化,因此我面临着SerializationException

limitations: 局限性:

the non-serialized type is in external assembly/dll. 非序列化类型在外部Assembly / dll中。 So i cannot mark it as serializable with attribute. 所以我不能将其标记为可序列化的属性。

If you want to pass it through the remoting infrastructure it must be either by ref or serializable. 如果要通过远程处理基础结构传递它,则必须通过ref或可序列化。

Since this type is neither you have limited options: 由于这两种类型都不是,因此您的选择有限:

  1. Perform the processing in the remote app domain. 在远程应用程序域中执行处理。
  2. Perform custom serialization to transfer the data you want (not the object). 执行自定义序列化以传输所需的数据(不是对象)。 For example, copy the values to a serializable DTO class or use a serializer library. 例如,将值复制到可序列化的DTO类或使用序列化程序库。

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

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