I have a WCF service hosted in IIS. The intention is for clients to make a call and receive a custom class that is defined in another project/dll. I have generated a service client using the svcutil.exe. The problem is this autogenerated client contains a new partial / proxy definition for the class I am trying to return from the service. It now throws a conversion error between my original custom class and the new partial definition at compile time. So how do you return user defined types from a WCF service? Advice appreciated.
Share
Just to second Yossi’s/Rich’s thoughts:
I have gone down this road before, and in some ways wish I hadn’t. Re extensibility / custom serialization – you have to be very careful. A bit easier if you use a pre-rolled serializer such as protobuf-net (which can integrate directly into WCF, and which is designed with extensibility in mind), but not easy.
Actually, one advantage of sharing the classes is that it makes it a bit easier to test: since you have the same
IFooeverywhere, you can mock thatIFoowith reasonable chance of success. It is harder to mock when the proxy gets involved (as you change more moving parts between the test code and the production code).