I am trying to host two services using a single console app. However, when I am trying to do so, only one service gets hosted, while the other does not.
Program.cs:<
Your first service jumps out of the using
block and so is disposing too early. Try this...
using (ServiceHost host = new ServiceHost(typeof(WWWCF.Login)))
using (ServiceHost host1 = new ServiceHost(typeof(WWWCF.UserRegistration)))
{
host.Open();
Console.WriteLine("Service1 Started");
host1.Open();
Console.WriteLine("Service2 Started");
Console.ReadLine();
}
Take a look at this: http://msdn.microsoft.com/en-us//library/yh598w02.aspx
You're instantly closing the first, since it's in the using. You need to set it up so the first using scope doesn't end until after the ReadLine()
call.
Try:
using (ServiceHost host = new ServiceHost(typeof(WWWCF.Login)))
{
host.Open();
Console.WriteLine("Service1 Started");
using (ServiceHost host1 = new ServiceHost(typeof(WWWCF.UserRegistration)))
{
host1.Open();
Console.WriteLine("Service2 Started");
Console.ReadLine();
}
}