none
Deserialize problem for an old serialized .bin file RRS feed

  • Question

  • Hi,

    I made an old vs2010 C# program that serialized some .bin files. The same program has a Deserialization function that is working well and reading the serialized files:

    However, I copied the same code to another new project to read the same serialized files from the old project. The code, unfortunately, cannot deserialize the file and I got the following error:

    I copied the folder named 'SoftMatchingAssociations' from the old project to the new one, but the problem still exists.

    Help me please correct my issue.

    Thank you so much in advance,

    Aya.


    Aya Zoghby

    Thursday, December 28, 2017 11:49 AM

Answers

  • Check the old files; if there is a SoftMatchingAssociations.dll file, then try copying it to a similar relative location of your new project. But if you want to work with objects after deserialisation, and there is a old SoftMatchingAssociations project that can be added to new solution and can be built, then try adding a project reference in the Add Reference dialog. See the structure of old solution too.





    • Edited by Viorel_MVP Thursday, December 28, 2017 6:44 PM
    • Marked as answer by ZoghbyAya Friday, December 29, 2017 4:04 PM
    Thursday, December 28, 2017 6:39 PM

All replies

  • VTS for serialized objects wasn't supported until .NET 2.0. As part of serialization IIRC the fully qualified type name is embedded in the data so the deserializer can recreate it. Simply copying the code to a new assembly would change the fully qualified name and therefore prevent deserialization.

    I suspect you'll have to do custom deserialization (perhaps with a surrogate selector) in order to rebuild the object. I've never had to try this so I cannot say whether it'll actually work or not. A lot of it depends upon the original object that was serialized and the attributes used. Everything I've ever done and read about with serialization requires the type information to be known up front. But I have seen some third party libraries that someone deserialize unknown types. You could also look into them.


    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, December 28, 2017 3:11 PM
    Moderator
  • Check the old files; if there is a SoftMatchingAssociations.dll file, then try copying it to a similar relative location of your new project. But if you want to work with objects after deserialisation, and there is a old SoftMatchingAssociations project that can be added to new solution and can be built, then try adding a project reference in the Add Reference dialog. See the structure of old solution too.





    • Edited by Viorel_MVP Thursday, December 28, 2017 6:44 PM
    • Marked as answer by ZoghbyAya Friday, December 29, 2017 4:04 PM
    Thursday, December 28, 2017 6:39 PM
  • Hi ZoghbyAya,

    >>I copied the folder named 'SoftMatchingAssociations' from the old project to the new one, but the problem still exists.

    Is there something different between your old project and new project? Please check the other files from old project. Do you miss some files when you copy the SoftMatchingAssociations folder from the old project to new project. Is it the same version of Visual Studio and .net framework?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 29, 2017 7:39 AM
    Moderator
  • Thank you. That solved m problem.

    Regards,

    Aya.


    Aya Zoghby

    Friday, December 29, 2017 4:05 PM