<tfoot id='TYGL7'></tfoot>
  • <i id='TYGL7'><tr id='TYGL7'><dt id='TYGL7'><q id='TYGL7'><span id='TYGL7'><b id='TYGL7'><form id='TYGL7'><ins id='TYGL7'></ins><ul id='TYGL7'></ul><sub id='TYGL7'></sub></form><legend id='TYGL7'></legend><bdo id='TYGL7'><pre id='TYGL7'><center id='TYGL7'></center></pre></bdo></b><th id='TYGL7'></th></span></q></dt></tr></i><div id='TYGL7'><tfoot id='TYGL7'></tfoot><dl id='TYGL7'><fieldset id='TYGL7'></fieldset></dl></div>
    <legend id='TYGL7'><style id='TYGL7'><dir id='TYGL7'><q id='TYGL7'></q></dir></style></legend>
        <bdo id='TYGL7'></bdo><ul id='TYGL7'></ul>

        <small id='TYGL7'></small><noframes id='TYGL7'>

        C# BinaryFormatter - 使用另一个命名空间中的对象反

        时间:2023-06-03

        <small id='dk67h'></small><noframes id='dk67h'>

          • <bdo id='dk67h'></bdo><ul id='dk67h'></ul>
            <i id='dk67h'><tr id='dk67h'><dt id='dk67h'><q id='dk67h'><span id='dk67h'><b id='dk67h'><form id='dk67h'><ins id='dk67h'></ins><ul id='dk67h'></ul><sub id='dk67h'></sub></form><legend id='dk67h'></legend><bdo id='dk67h'><pre id='dk67h'><center id='dk67h'></center></pre></bdo></b><th id='dk67h'></th></span></q></dt></tr></i><div id='dk67h'><tfoot id='dk67h'></tfoot><dl id='dk67h'><fieldset id='dk67h'></fieldset></dl></div>
            • <legend id='dk67h'><style id='dk67h'><dir id='dk67h'><q id='dk67h'></q></dir></style></legend>
                  <tbody id='dk67h'></tbody>

                1. <tfoot id='dk67h'></tfoot>

                  本文介绍了C# BinaryFormatter - 使用另一个命名空间中的对象反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  最近,我们将部分代码移至不同的项目库.

                  Recently, we moved a part of our code to different project library.

                  不幸的是,这些数据似乎已使用 BinaryFormatter 序列化到数据库中(不要问我为什么,我不知道,我讨厌这个想法).

                  Unfortunately, it appears that those data have been serialized into the database with a BinaryFormatter(don't ask me why, I don't know and I hate this idea).

                  现在我负责创建一个更新数据库的更新工具(当我们的软件检测到需要更新的数据库时,该工具会根据版本自动启动):

                  Now I'm responsible to create an update tool that update the database(The tool is launched automatically by our software when it detects a database that need updates, based on version):

                  1. 创建新列
                  2. 反序列化二进制列
                  3. 将反序列化的列写入新列
                  4. 删除旧的二进制列

                  我的问题是,当我尝试反序列化时,它告诉我:

                  My problem is that when I try to deserialize, it tells me that :

                  Unable to find assembly 'MyOldAssemblyName, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a5b9cb7043cc16da'.
                  

                  但是这个程序集已经不存在了.将此类放入我的更新程序"项目中没有问题,但我无法保留这个旧项目只包含此文件.

                  But this assembly doesn't exists anymore. I've no issue to put this class in my "updater" project, but no way that I can keep this old project only to contains this file.

                  有没有办法向 BinaryFormatter 指定它必须用指定的类反序列化它接收到的 Stream?

                  Is there a way to specify to the BinaryFormatter that it has to deserialize the Stream it receives with a specified class?

                  或者说程序集被重命名了,或者???

                  Or say that the assembly has been renamed, or ???

                  推荐答案

                  其实我觉得我自己找到了解决方案.

                  In fact I think I found myself the solution.

                  我们可以为二进制格式化程序提供一个 SerializationBinder,这将允许我们手动解析在流中找到的类.

                  We can give a SerializationBinder to the binary formater, which will allows us to resolve manually a class we found in the stream.

                  更多信息这里

                  这篇关于C# BinaryFormatter - 使用另一个命名空间中的对象反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:.NET 十进制的二进制表示 下一篇:不寻常的整数编码到字节 - 这是什么方案?

                  相关文章

                  最新文章

                    <tfoot id='QrQwl'></tfoot>
                    <i id='QrQwl'><tr id='QrQwl'><dt id='QrQwl'><q id='QrQwl'><span id='QrQwl'><b id='QrQwl'><form id='QrQwl'><ins id='QrQwl'></ins><ul id='QrQwl'></ul><sub id='QrQwl'></sub></form><legend id='QrQwl'></legend><bdo id='QrQwl'><pre id='QrQwl'><center id='QrQwl'></center></pre></bdo></b><th id='QrQwl'></th></span></q></dt></tr></i><div id='QrQwl'><tfoot id='QrQwl'></tfoot><dl id='QrQwl'><fieldset id='QrQwl'></fieldset></dl></div>
                  1. <small id='QrQwl'></small><noframes id='QrQwl'>

                      <legend id='QrQwl'><style id='QrQwl'><dir id='QrQwl'><q id='QrQwl'></q></dir></style></legend>
                      • <bdo id='QrQwl'></bdo><ul id='QrQwl'></ul>