Reputation: 57
I'm creating a solution in C# using WCF Service. There is one project which has Service References set to My WCF Service, however I'll be using data structures from the server through multiple project. I'm wondering if it's better to using struct created in References to WCF Service or add reference to library which is created while Service is built?
Upvotes: 0
Views: 133
Reputation: 33139
It depends, as usual.
If your data structures are just that -- they hold data (properties) and do not contain any logic -- then it doesn't really matter. What the Service Reference proxy generator creates is basically the equivalent of the data types you have created in the service.
If you do want to have logic on those structures, and that logic applies to both the client and the server, it is best to put those classes in a shared library.
Of course this means that, when the service uses a newer version of that shared library, the client must do so too (although that would in reality depend on whether the changes you introduce are breaking, such as renaming or removing a property).
Upvotes: 1