如何获得的BinaryFormatter到在一个不同的应用反序列 [英] How to get BinaryFormatter to deserialize in a different application

查看:173
本文介绍了如何获得的BinaryFormatter到在一个不同的应用反序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用BinaryFormatter的序列化类实例的数组到一个文件中。我可以在同一个应用程序中的反序列化这一优良。当我尝试同样的反序列化在不同的应用程序(即拉在做工作的共同文件),然后我得到了以下错误:

I am using BinaryFormatter to serialize an array of class instances to a file. I can deserialize this fine within the same application. When I try the same deserialization in a different application (that pulls in a common file that does the work) then I get the following error:

{"Could not load file or assembly 'pmlscan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The module was expected to contain an assembly manifest."}

其中pmlscan是原申请的名称。我如何获得的BinaryFormatter不尝试加载pmlscan?

where pmlscan is the name of the original application. How do I get BinaryFormatter to not try and load pmlscan?

推荐答案

您可以通过使用自定义SerializationBinder实现它。在这里看到:<一href="http://www.$c$cproject.com/KB/cs/DrawWithMouse.aspx#AdvancedBinarySerialization%3aDeserializinganObjectIntoaDifferentTypeThantheOneItwasSerializedInto9">Advanced二进制序列化:反序列化对象到不同类型比它被序列化到

You can achieve it by using custom SerializationBinder. See here: Advanced Binary Serialization: Deserializing an Object Into a Different Type Than the One It was Serialized Into

这篇关于如何获得的BinaryFormatter到在一个不同的应用反序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆