ServiceHost不引发事件

时间:2019-06-07 10:59:31

标签: c# .net wcf

我有一种非常简单的WCF服务,只有一种方法,除一件事情外,其他所有东西都可以正常工作。服务不会引发Opened事件。

class Program
{
    static void Main(string[] args)
    {
        using (System.ServiceModel.ServiceHost host = new
                      System.ServiceModel.ServiceHost(typeof(HelloService)))
        {
            host.Open();
            host.Opened += HostOpenned;
            Console.WriteLine("Host started @ " + DateTime.Now.ToString()); // This is printed properely
            Console.ReadLine();
        }
    }



    private static void HostOpenned(object s, EventArgs eventArgs)
    {
        Console.WriteLine("openned..."); // This text does not shows on console
    }
}

0 个答案:

没有答案