Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 236391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:20:29+00:00 2026-05-11T20:20:29+00:00

In .NET 2.0 (and upwards, I presume), Version Tolerant Serialization will succesfully deserialize a

  • 0

In .NET 2.0 (and upwards, I presume), Version Tolerant Serialization will succesfully deserialize a serialized object from an older version of the assembly in which the object resides.

When I open such a binary formatted serialized stream using a hex viewer (a simple drag’ndrop into VS will do) I can see there’s assembly information contained in this stream.

Is there, during deserialization, a way to retrieve this information? This can be used, for example, to apply fixups to known issues when reading in older content.

UPDATE:
It looks like it can’t be done (apart from changing the class itself, as in Paul Betts answer, didn’t test that either) so is there any other way to read this value? Is the binary format published?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:20:29+00:00Added an answer on May 11, 2026 at 8:20 pm

    I discovered these serialization issues first-hand while writing this CodeProject article (scroll to ‘Loading the Catalog from Disk’, about half-way down).

    Basically I was serializing something with an ASP.NET application – and the serialized data could not be read after the IIS Application was restarted (due to the whole dynamic compilation/temporary assembly cache/etc that ASP.NET does)! Ouch!

    Anyway, my first point is the Exception thrown during deserialization includes the strong name

    Cannot find the assembly h4octhiw, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

    so obviously you are correct that the information you want is in there “somewhere”. Theoretically (and yes, this is a TERRIBLE idea) you could catch serialization exceptions and parse the error for the older version details (of course ‘current’ deserialization will work without throwing)… BUT there might also be a better way…

    The second point relates to the solution I implemented (using this info). I wrote a custom System.Runtime.Serialization.SerializationBinder: the is shown code below as an example.

    public class CatalogBinder: System.Runtime.Serialization.SerializationBinder
    {
        public override Type BindToType (string assemblyName, string typeName) 
        { 
            // get the 'fully qualified (ie inc namespace) type name' into an array
            string[] typeInfo = typeName.Split('.');
            // because the last item is the class name, which we're going to 
            // 'look for' in *this* namespace/assembly
            string className=typeInfo[typeInfo.Length -1];
            if (className.Equals("Catalog"))
            {
                return typeof (Catalog);
            }
            else if (className.Equals("Word"))
            {
                return typeof (Word);
            }
            if (className.Equals("File"))
            {
                return typeof (File);
            }
            else
            {    // pass back exactly what was passed in!
                return Type.GetType(string.Format( "{0}, {1}", typeName, 
                                    assemblyName));
            }
        } 
    }
    

    Basically BindToType is being given the opportunity by the deserialization process to ‘substitute’ a known Type for the one originally used to serialize THAT OBJECT. I am only using the typeName, but the assemblyName probably contains the information you are after, AND a custom SerializationBinder is probably the method you should investigate to ‘use’ it.

    FYI, the code above was ‘wired up’ like this:

    System.Runtime.Serialization.IFormatter formatter = 
        new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
    formatter.Binder = new CatalogBinder(); // THIS IS THE IMPORTANT BIT
    object deserializedObject = formatter.Deserialize(stream); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

net webforms application which is a new version of an old webshop. I have
.NET allows to extend XSLT by using the so called extension object. Very handy
I'm working with an asp.net application that produces large PDF documents from HTML. The
.net class SynchronizedReadOnlyCollection has 4 constructors. public SynchronizedReadOnlyCollection(); public SynchronizedReadOnlyCollection(object syncRoot); public SynchronizedReadOnlyCollection(object syncRoot,
I just switched over to WPF from just regular C# .NET for the more
My .Net Windows Forms application generates a PDF report, which I want to show
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
.NET, Java and other high level database API's in various language often provide techniques
.NET developers out there! Need your opinion here! I am now using Visual Assist
.Net Compact Framework Scenario: User is on a screen. Device can't finds a printer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.