2

Let me briefly explain my architecture before I ask my question. I have a client application that calls out to a web service and passes it a couple of items of data. The web service uses this data to do some lookups and then returns a binary serialized object, by using the BinaryFormatter, as a byte array to the client. The client then deserializes the object and uses it. My problem is I had to rename the assembly that the server uses for the new version. This has caused a problem when deserializing in the client. It is not an option for me to deploy a new client just so the new assembly name can be used so my question is, is there a way I can change the Assembly Name that is being written during serialization. I know how to use SerializationBinders for deserializing but that does not solve my problem as that would require deploying a new client.

I am currently using C# 2.0 for both the win forms application and the web service.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Matt
  • 1,354
  • 10
  • 18

2 Answers2

0

You can recreate an empty assembly with the old name containing just the AssemblyInfo.cs, where you put a type redirect: [assembly: TypeForwardedTo(typeof(MyClassName))], for every type that is moved to another assembly. Ofc this assembly should reference the new one.

But generally consider not using binary serialization for complex data structures, because it's not friendly to such changes as moving types between assemblies.

0

If I were using .NET 4 the solution from Thomas would have been perfect. However, .NET 2.0 does not provide this functionality. Instead I just renamed the dlls back to what they were. I would like to eventually rename the dlls but at this point I have not found a viable solution where I would not have to deploy something to the client as well.

Matt
  • 1,354
  • 10
  • 18