我的应用程序生成一个新类型Foo并将其写入新程序集。 然后我创建一个Foo类型的对象并序列化它。 如果我删除程序集并在我尝试反序列化Foo对象时重新创建它,它告诉我无法将类型Foo转换为Foo类型。 它认为那些是不同的类型。 有没有办法来解决这个问题?
编辑:我无法控制序列化。 编辑:我们发现版本guid总是不同的。 这个指南是什么以及我们如何指定它?
My app generates a new type Foo and writes it to new assembly. Then I create an object of type Foo and serialize it. If I delete the assembly and recreate it when I try to deserialize the Foo object it tells me that cannot convert type Foo to type Foo. It thinks those are different types. Is there a way to fix this?
EDIT: I have no control over the serialization. EDIT: We found that the version guid is always different. What is this guid and how we can specify it?
最满意答案
我认为当您使用二进制格式化程序时,模块版本ID(MVID)是在序列化中编写的。 当您想要反序列化时,它会使用该MVID搜索程序集中的类型。 这是坏事。 您无法控制MVID。 这是好事。 您可以打开dll文件,查找并替换您的MVID。 我通过使用十六进制编辑器更改MVID来测试它,它可以工作。
I think that the module version id (MVID) is written in the serialization when you use binary formatter. When you want to deserialize it searches for the type in assembly with that MVID. Here is the bad. You do not have control over MVID. Here is the good. You can open the dll file, find and replace the MVID with yours. I tested that by changing the MVID with hex editor and it works.
更多推荐
发布评论