Reputation: 993
Here's the setup, I had a collection class in MyAssembly
that looked like so:
[Serializable()]
public class MyCollection : List<MyItem> //MyItem is also serializable
{
public string MyProperty{ get; set; }
//some methods for use by the current assembly
}
And I had an application that made a reference to a wcf service, which in turn had a reference to this MyAssembly
.
The problem: In the past we've made many changes to the classes without any issues, however I recently added a couple of new methods(no new properties) to MyCollection
and after recompiling and redeploying the wcf service, the app consuming the service would all of a suddent return a null MyCollection
when being called.
The solution and question: Updating the service reference in the app brought everything back to normal, but my question is why? I was under the understanding that new items could be added to your classes without having to update the reference unless something was changed or deleted. Can someone explain this or refer me somewhere?
Upvotes: 1
Views: 110
Reputation: 6805
When you add reference to wcf service a copy (not actual real copy, more like a proxy objects) of service objects are placed on client side. So when you update wcf service objects client is still left only with old (invalid) copy. You should always update reference on client side when changes are made on wcf server ServiceContract or DataContract.
Upvotes: 1