static void

WCF Clients

See Faults for error trapping FaultException/ TimeoutException and client.Abort() (don't use "using")

WCF ClientBase

Client proxies (via Visual Studio Service Reference, or svcutil, or manual) inherit ClientBase<IService>


When you have shared DLLs between client and service, you don't have to use svcutil/Service Reference to generate a proxy. Instead create the proxy dynamically using ChannelFactory<T>:

using (var factory = new ChannelFactory<IService>(
    new NetTcpBinding(),
    var proxy = factory.CreateChannel();
    var result = proxy.Add(1, 2);

Async Clients

Generate async code (in VS Service Reference/Advanced):

Async with AsyncCallback

using(var proxy = new CalculatorClient())
    var cb = new AsyncCallback(
        (asyncResult) =>
                var client = (CalculatorClient)asyncResult.AsyncState ;
                var result = client.EndAdd(asyncResult);
    proxy.BeginAdd(1, 2, cb, null);

Async with *Completed event

using (var client = new Service1Client())
    client.GetDataCompleted += (sender, e) =>
                                       var result = e.Result;