I like to structure my WCF solutions as follows:
Contracts (class library)
Contains all service contracts, operations, failures, and data. It can be shared between server and client in a clean .NET-.NET script.
Service implementation (class library)
Contains code for implementing services and any helper / helper methods needed to achieve this. Nothing more.
Service host (optional - may be Winforms, console application, NT service)
Contains a service host for debugging / testing, or possibly also for production.
This basically gives me the server side of things.
On the client side:
Client proxies (class library)
I like to pack my client proxies into a separate class library so that they can be reused by multiple actual client applications. You can do this using svcutil or the “Add Service Reference” and manually configure the awful app.config that you receive or manually implement client proxies (when using the contract assembly) using the ClientBase<T> or ChannelFactory<T> constructs.
1-n actual customers (any application)
Usually it will refer only to the assembly of client proxies, or, perhaps, to the assembly of contracts, if it will be used together. It can be ASP.NET, WPF, Winforms, a console application, other services - you name it.
Thus; I have a beautiful and clean layout, I use it consistently over and over again, and I really think that made my code cleaner and more convenient to maintain.
It was inspired by Miguel Castro Extreme WCF Screen on DotNet Rocks TV with Karl Franklin - highly recommended screening!
marc_s
source share