.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > BinaryFormatter.Deserialize and AssemblyVersion
 

BinaryFormatter.Deserialize and AssemblyVersion

Hello
I'm using BinaryFormatter.Deserialize (System.Runtime.Serialization.Formatters.Binary namespace) to deserialize a file which was serialized with BinaryFormatter.Serialize.

We're using [assembly: AssemblyVersion("2.3.*")] in AssemblyInfo.cs, so a new Build Number and Revision is generated on every build.

This lead to that the deserializer throw an exception when Deserialize files which was Serialized with older assemblies.

Is it possible to tell the deserializer to look on just the Major and Minor version in AssemblyVersion, and NOT throw exception if just Build Number and Revision has changed?

JI

janid1967

JI,

There is no way to specify to the BinaryFormatter to ignore just the Major and Minor version of AssemblyVersion, but you can always ignore the version number altogether by using the AssemblyFormat property of the BinaryFormatter you are using.

Use something like this:

formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;

This tells the BinaryFormatter that the assembly used during deserialization does not need to match exactly the assembly used for serialization. Part of this is that VersionNumber does not need to match.

Hope this helps,

-Chris

Christopher Scrosati - MSFT

JI,

There is no way to specify to the BinaryFormatter to ignore just the Major and Minor version of AssemblyVersion, but you can always ignore the version number altogether by using the AssemblyFormat property of the BinaryFormatter you are using.

Use something like this:

formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;

This tells the BinaryFormatter that the assembly used during deserialization does not need to match exactly the assembly used for serialization. Part of this is that VersionNumber does not need to match.

Hope this helps,

-Chris

Christopher Scrosati - MSFT

You can use google to search for other answers

Custom Search

More Threads

• Desingn Question
• Windows service remoting
• Problems authenticating a webservice using soap
• Binary Serialization of Unpaired Surrogate Characters
• Proxy type question
• How to use GlobalResourceObject in Diffrent Component
• Change MarshalByRefObject to Serializable Does what?
• Remoting crashes IIS
• Deserializing Delegates/RuntimeMethodInfo
• A question about proxies