Question

When I use svcutil or some other proxy generator it creates appropriate classes in client. I wonder what is the best way to store this classes to avoid conflicts.

  • In some other "Common" project and remove generated classes from proxy?
  • Or just use original classes in service and theese duplicated in proxy?
Was it helpful?

Solution

There are two ways to handle the code for service and data contract classes WCF clients.

  • Generate everything using svcutil.exe. Don't have any kind of reference from your client project to the service assembly. Just use the classes generated by svcutil.
  • Reference the assemblies containing the types directly. I sometimes use a separate assembly for my DTO classes, that is references from both the client and the server. When generating the client code with svcutil, use the /reference:<file path> option to tell svcutil to reuse the types from an existing assembly instead of regenerating them.

If you reference the origin assembly, without passing it with /reference to svcutil you'll end up with a mess of conflicts. I guess that's what happened to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top