When you also want to expose metadata without a config file you can build on the example programmatically creating a ServiceHost:
public ConsoleHost()
{
mHost = new ServiceHost(typeof(Example), new Uri("http://localhost:8000/Example"), new Uri("net.tcp://9000/Example"));
NetTcpBinding tcp = new NetTcpBinding();
mHost.AddServiceEndpoint(typeof(IExample), tcp, "net.tcp://localhost:9000/Example");
ServiceMetadataBehavior metaBehavior = mHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metaBehavior == null)
{
metaBehavior = new ServiceMetadataBehavior();
metaBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
metaBehavior.HttpGetEnabled = true;
mHost.Description.Behaviors.Add(metaBehavior);
mHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
}
mHost.Open();
}