Peter17
Peter17

Reputation: 3092

Problem with deserialization after renaming assembly

I have a following problem. In order to change a name of the compiled executable file, I changed the name of the Assembly. But after that I couldn't open an old binary serialized object from the file. I have an SerializationException: "Unable to find assembly "OldAssembly".

I know that it can be solved somehow by creating custom SerializationBinder and overriding BindToType mehod there. But I don't know how to do that.

Any tips or hints are appreciated.

Upvotes: 1

Views: 574

Answers (1)

James Michael Hare
James Michael Hare

Reputation: 38397

Did you use [DataContract] or [Serializable] to mark your objects for serialization?

If you use DataContract you can change the xml namespace on your new object so it won't look for the old assembly/type:

[DataContract(Namespace = "http://schemas.datacontract.org/2004/07/Your.Old.Namespace.ClassName")]

I did this recently when I was moving a serialized type from one assembly to another.

Upvotes: 1

Related Questions