---
title: "Solving Binary serialization versioning conflicts - The HashTable problem"
url: "https://osherove.com/blog/2005/4/6/solving-binary-serialization-versioning-conflicts-the-hashta.md"
canonical: "https://osherove.com/blog/2005/4/6/solving-binary-serialization-versioning-conflicts-the-hashta.html"
published: "2005-04-06T19:44:00"
updated: "2005-04-06T19:44:00"
tags: [".Net Quotations"]
author: "Roy Osherove"
description: "A while ago I posted about a solution to Binary Serialization version conflicts , via Jonathan Einav. A comment was posted on that blog post regarding a problem to which Jonathan is replying through me via email, and…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Solving Binary serialization versioning conflicts - The HashTable problem

By Roy Osherove April 6, 2005 In [.Net Quotations](https://osherove.com/blog/category/net-quotations)

**Historical article** · Originally published April 6, 2005; technical details may be outdated.

A while ago I posted about [a solution to Binary Serialization version conflicts](https://weblogs.asp.net/rosherove/archive/2005/03/03/384267.aspx), via Jonathan Einav. A comment was posted on that blog post regarding a problem to which Jonathan is replying through me via email, and for which you can download the latest version of the fixed class:

Download the file here: [files.osherove.com/downloads/VersionSupportingBinaryFormatter.zip](http://files.osherove.com/downloads/VersionSupportingBinaryFormatter.zip)

The problem exists when trying to serialize a HashTable, and Jonathan provides a fix here.

"Roy,

 Attached is the VersionSupportingBinaryFormatter, with a bug fix of a problem that was raised in your blog regarding deserialization of hashtables with the VersionSupportingBinarySerializer.

The problem was that the hashtable class implements the OnDeserialization method (defined in IDeserializationCallback),

**if** **(**buckets!=null**)**
**{**
       return; //Somebody had a dependency on this hashtable and fixed us up before the ObjectManager got to it.
**}**
**if** **(**m\_siInfo==null**)**
**{
**        throw new SerializationException**(**Environment.GetResourceString**(**"Serialization\_InvalidOnDeser"**))**;
**}
**

the first lines of code in the hashtable.cs OnDeserialize are:

 The m\_siInfo is being assigned when the SerializationInfo (ISerializable) constructor is called.

When I register the surrogate I run over that call, which made me think it is stupid to do it any how, due to the fact that custom serialization behaviors will not be reproduce when my reflection surrogate is called, so I do not register any more the VersionSupportingSerializationSurrogate for classes that implements the ISerializable interface.

Cheers,

****Jonathan                  Einav****

Software  Project  Manager"

## More in .Net Quotations

[All posts in .Net Quotations](https://osherove.com/blog/category/net-quotations)

- Apr 8, 2005

    ### [TimedLock class: helping find and avoid deadlocks in your multithreaded code](https://osherove.com/blog/2005/4/8/timedlock-class-helping-find-and-avoid-deadlocks-in-your-mul.html)

- Apr 8, 2005

    ### [Defensive event publishing, a different approach](https://osherove.com/blog/2005/4/8/defensive-event-publishing-a-different-approach.html)

- Mar 11, 2005

    ### [CLR Performance Q&A, and how it relates to unit testing and mock objects](https://osherove.com/blog/2005/3/11/clr-performance-qampa-and-how-it-relates-to-unit-testing-and.html)

- Feb 1, 2005

    ### [Launcher: Clean auto-deployment and auto-updating code from Franklins.Net](https://osherove.com/blog/2005/2/1/launcher-clean-auto-deployment-and-auto-updating-code-from-f.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
