Subscribe to events within a WCF service

后端 未结 3 1842
广开言路
广开言路 2020-12-30 08:55

I have a need to do some real-time reporting on the functionality of a WCF service. The service is self-hosted in a windows app, and my requirement is to report \"live\" to

3条回答
  •  时光说笑
    2020-12-30 09:03

    You seem to be instantiating a default ServiceHost class:

    service = new ServiceHost(typeof(MyService));
                  ***********
    service.outputMessage += new MyService.MessageEventHandler(frm2_outputMessage);
      // the above line does not work!
    

    and I highly doubt that would have a "outputMessage" property for an event handler.

    Shouldn't you be instantiating your own custom service host, something like this:

    class MyCustomServiceHost : ServiceHost
    {
      ...... your custom stuff here ......
    }
    
    service = new MyCustomServiceHost(typeof(MyService));
                  *******************
    service.outputMessage += new MyService.MessageEventHandler(frm2_outputMessage);
    

    ??

    Marc

提交回复
热议问题