Kirk G

I'm currently using the BinaryFormatter to serialize a class to give me a simple way to save a class structure to disk and load it again later (this works fine). I tried creating a second application that should also be able to read the serialized classes created by the first app. In the second app, the BinaryFormatter.Deserialize() function returns an exception saying it cannot find the assembly with the name of the first app. If I rename the second app to have the same name as the first then everything works fine, but this is not acceptable. Is there anyway to have a second app deserialize a class that was serialized by a first app using BinaryFormatter If not is there another easy way Thanks

Kirk



Re: .NET Remoting and Runtime Serialization BinaryFormatter Deserialization Seems Assembly Specific

Kirk G

I have found a work around that works, but is still not ideal. The work around is to create a DLL assembly with the same name as my first app (obviously ending in .dll instead of .exe though) that has the code to deserialize the class. My second app then references this new dll and uses it to deserialize the class that was serialized with the first app. It seems like there should be a flag that could be set on the BinaryFormatter to not require the deserializing assembly to have the same name as the serializing assembly. Any tips would be appriciated. Thanks

Kirk





Re: .NET Remoting and Runtime Serialization BinaryFormatter Deserialization Seems Assembly Specific

Richard Hough

Serialization is not only assembly-specific, it is data-specific. If you ever change any fields of your serialized classes your idea will no longer work. This will, in general, prevent any other application from reading serialized data from your application and is by design.

If you want to exchange data between applications you want an interchange format, like XML or RIFF. Check out the System.Xml.XmlTextReader, and XmlTextWriter classes.




Re: .NET Remoting and Runtime Serialization BinaryFormatter Deserialization Seems Assembly Specific

Vipul Modi - MSFT

Look at the XmlSerializer or DataContractSerializer for serializing the data in XML.

- Vipul Modi - MSFT






Re: .NET Remoting and Runtime Serialization BinaryFormatter Deserialization Seems Assembly Specific

alex2323

another way :
Serialization Studio