Creating a ServiceHost programmatically (without config file) in its most basic form:
namespace ConsoleHost
{
class ConsoleHost
{
ServiceHost mHost;
public Console()
{
mHost = new ServiceHost(typeof(Example), new Uri("net.tcp://localhost:9000/Example"));
NetTcpBinding tcp = new NetTcpBinding();
mHost.AddServiceEndpoint(typeof(IExample),tcp,"net.tcp://localhost:9000/Example");
}
public void Open()
{
mHost.Open();
}
public void Close()
{
mHost.Close();
}
public static void Main(string[] args)
{
ConsoleHost host = new ConsoleHost();
host.Open();
Console.ReadLine();
host.Close();
}
}
}