The Contract

public interface IPouet
[OperationContract, ProtoBehavior]
Toto HelloWorld();

[OperationContract, ProtoBehavior]
Toto HelloWorldException();

The Implementation

Create an application console

The Implementation must is hosted directly.

public class Pouet : IPouet
public Toto HelloWorld()
return new Toto { Name = "sfgdfg" };

public Toto HelloWorldException()
throw new FaultException<MyFault>(new MyFault { Info = "aie" });

Then the class Program.cs

The abstract class EntryPointBase depend of WcfHost which is a windows service WCF self hosted.
Inversion of Control is done with Unity and is setuped into WcfHostUnityProvider.
If you have to setup service dependencies, you have just to override Setup Method from WcfHostUnityProvider.

public class Program : EntryPointBase<WcfHost, WcfHostUnityProvider>
public static void Main(string[] args)

Setup the Config File :

<section name="hostConfiguration" type="Framework.Wcf.Conventions.HostConfiguration, Framework.Wcf.Conventions"/>

<hostConfiguration configSource="HostConfiguration.config"/>


<add mode="Prod" host="localhost" port="10300" binding="netTcpBinding"/>

In order to share config, we use configSource. Client must reference this config by adding as link.

All of this code Run into Framework.Wcf.ServiceImplementation for hosting service and Framework.Wcf.Consumer for client

Last edited Apr 23, 2013 at 7:55 PM by cboudereau, version 2


No comments yet.