I have a following sample project:
namespace ConsoleApplication1
{
[ServiceContract]
public interface IFoo
{
[OperationContract]
string GetText();
}
public class Foo : IFoo
{
public string GetText()
{
return "foo";
}
}
class Program
{
static void Main(string[] args)
{
using (var host = new ServiceHost(typeof(Foo), new Uri("http://localhost:9995/foo")))
{
host.AddServiceEndpoint(typeof(IFoo), new BasicHttpBinding(), "");
//new Control();
host.Open();
Console.ReadKey();
}
}
}
}
Which works OK, by when I uncomment line new Control()
and run the application again, the service stops to work.
Does someone know why it is happening? Why creating a new Control before calling host.Open()
, stops the WCF service from working?
Note: I found out this problem after debugging a big project where some services weren't working. It appeared that the services with which there is a problem were created only after some UserControl
has been created.