【发布时间】:2013-02-20 22:15:11
【问题描述】:
所以我找到了很多关于这个主题的主题,但我认为我还没有找到适用的主题。
基本上,我的 .exe 加载一个 .dll (MyAssembly) 文件,该文件执行序列化和加载。显然它序列化得很好。
但是当我去反序列化 MyAssembly.dll 文件中的文件时,它会因本文标题中的错误而爆炸。
有人有什么想法吗?我不明白它怎么找不到调用代码的程序集!
我的代码:
// deserialize
using (var target = new System.IO.FileStream(Path, System.IO.FileMode.OpenOrCreate))
{
var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
var Obj = bin.Deserialize(target);
if (Obj != null)
{
ObjectToStore = (ObjectTypeInMyAssembly)Obj;
}
}
// serialize
using (var target = new System.IO.FileStream(Path, System.IO.FileMode.OpenOrCreate))
{
var bin = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
bin.Serialize(target, ObjectToStore);
}
【问题讨论】:
-
如果可以的话,如何显示代码崩溃的地方以及序列化代码的结构......
-
使用 fuslogvw.exe 解决程序集解析问题。
标签: c# serialization