Skip to main content

Posts

Showing posts with the label Namespace

How to handle different namespace between serialization and deserialization

Consider this scenario: You have a web service with entries in a namespace Company.Business.Entities You have matching entities on the client side in a namespace Company.Client.Entities You want to simply serialize the Business Entity, transfer over the wire and deserialize  into client enetites. Problem!!!! you can't as the namespace is not same. Solution Put a namespace attribute on each client side and server side entity. e.g. [ DataContract (Namespace  =   "http://wwww.yourcompany.com/messages/entities" )] The problem with this is that you will have to add this to each and every entity.     2. Option 2 and probably better is to use assembly attribute in assemblyinfo.cs [ assembly :  ContractNamespace ( "http:// wwww.yourcompany.com/messages/entities " , ClrNamespace  =   "Company.Client.Entities" )] Add this to both, client and Business entities. Remember to update ClrNamespace and runtime will create corr...