I am implementing a WCF reference model this week as part of a presentation.

You realise some basics in the process of hosting your new services

  • Principle 1: Services needs hosting (adding a service to config doesn’t host it)

            ServiceHost host = new ServiceHost(t);

            host.Open();

·         Principle 2: Service and client proxy contracts should be aligned. Manual is better as it removes the unecessary junk configuration that the add service reference in Visual Studio provides. The auto generated proxy however does simply things provided you continue to refresh the proxy on each and every service change (think rebuild)

Note: If you don’t do this you may have a client unable to find a default endpoint element. Basically there is no service

Tips:

  • SvcTraceViewer from the Windows SDK is a lifesaver (look for unrecognised elements in your data contract and for categorised errors)
  • Namespaces (the client must use or specify the service hosts data contract namespace)
  • Avoid serialisation (stick to data contracts and collections or data contracts)

Links:

Windows® Software Development Kit (SDK) for Windows Vista™.  

A nice site (also delivering the WCF master class) is here:

Remember to switch on and off diagnostics. The easy way is to add the following configuration line to your application configuration:

  <system.serviceModel>

    <diagnostics performanceCounters="All" />