反序列化时C#强制转换错误

反序列化时C#强制转换错误,c#,serialization,casting,binaryformatter,C#,Serialization,Casting,Binaryformatter,我正在尝试反序列化32位C#exceldna加载项中的二进制格式化程序,该加载项在64位C#应用程序中序列化 调用BinaryFormatter.Deserialize(流)时,会引发以下异常: [A]System.Tuple`3[System.Collections.Generic.Dictionary`2[System.String,System.Int32],System.Collections.Generic.Dictionary`2[System.String,MyExcelAddin

我正在尝试反序列化32位C#exceldna加载项中的二进制格式化程序,该加载项在64位C#应用程序中序列化

调用BinaryFormatter.Deserialize(流)时,会引发以下异常:

[A]System.Tuple`3[System.Collections.Generic.Dictionary`2[System.String,System.Int32],System.Collections.Generic.Dictionary`2[System.String,MyExcelAddin.MyPropertyNames],MyApplication.DataOutput] cannot be cast to 
[B]System.Tuple`3[System.Collections.Generic.Dictionary`2[System.String,System.Int32],System.Collections.Generic.Dictionary`2[System.String,MyExcelAddin.MyPropertyNames],MyApplication.DataOutput]. 

Type A originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. 

Type B originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.

类型A和B看起来完全相同,并且来自同一个库。这里出了什么问题,有什么线索吗?这是64位/32位的东西吗?

您使用的是什么版本的网络?我认为您需要使用一个版本的Net>=而不是它内置的版本。我还没有看到这个特定的场景,但坦率地说,这就是为什么不使用
二进制格式化程序的原因;更改序列化程序是未来的一个选项吗?或者这样做会对现有数据造成巨大破坏吗?一切都是使用.net 4.5构建的(mscorlib 4.0.0.0是否意味着.net 4.5?),我更喜欢使用BinaryFormatter,因为它比普通XML快得多,但值得一提的是,这似乎是因为在32位命名空间中定义了一个类,而64位命名空间中引用了该类。不知道为什么,但这解决了它。