I have a windows service that references an assembly which contains the following class.
[Serializable]
public class User
{
public User(string userName)
{
UserName = userName;
}
public string UserName { get; private set; }
}
This service has a method to allow us to create a User:
public User CreateUser(User user)
{
//Create and return user
}
Through remoting we are able to call this method in the service that takes in User object from our application. The application references the same assembly that the service does for the User class but it forces a specific 1.0.0.0 version.
CreateUser(User user);
We would like to change the existing assembly that is referenced from each project to add a new property "Phone" to the User class.
[Serializable]
public class User
{
public User(string userName)
{
UserName = userName;
}
public string UserName { get; private set; }
**public string Phone { get; set; }**
}
We will increment the assembly version from 1.0.0.0 to 2.0.0.0. The windows service will have a reference to the 2.0.0.0 version of the assembly in the GAC. Because some of our clients are slow at upgrading and they force specific versions of the assembly or copy it local they will still be referencing the 1.0.0.0 version.
With this change to the service assembly reference the marshaller that deserializes/serializes the object from the service to the application throws a serialization error. "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter..."
The change we made should be a non breaking change since we just added additional feature. Is there a way to allow the existing application continue and use the 1.0.0.0 version of the assembly and serialize the 2.0.0.0 without the new property down to them without some convoluted conversion on the service?
UPDATE:
We are using the following to connect over to our service
marshaller = ChannelFactory<T>.CreateChannel(new NetTcpBinding() { MaxReceivedMessageSize = MaxResponseSize }, new EndpointAddress(new Uri(new Uri(servers[serverIndex]), serviceName)));
Inner exception: http://tempuri.org/:CreateUserResult. The InnerException message was ''EndElement' 'CreateUserResult' from namespace 'http://tempuri.org/' is not expected. Expecting element '_someOtherField'.'. Please see InnerException for more details ...Next inner is null