title: Subscribe to events within a WCF service
body: <p>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 the host app when certain methods are called by the client.</p>
  
  <p>My initial thought on the task was to publish a "NotifyNow" event in the service code, and subscribe to the event in my calling app, but this doesn't seem to be possible.  Within my service code (implementation, not the interface) I have tried adding the following</p>
  
  <pre><code>public delegate void MessageEventHandler(string message);
  public event MessageEventHandler outputMessage;
  
  void SendMessage(string message)
  {
      if (null != outputMessage)
      {
          outputMessage(message);
      }
  }
  </code></pre>
  
  <p>and call the SendMessage method whenever I need to notify the host app of some action.  (This is based on what I remember of this kind of inter-form communication in a winforms app, and my memory may have let me down here...)</p>
  
  <p>When I try to hook up the event handler in my host, though, I can't seem to figure out how to attach to the events...  My hosting code is (in a nutshell) </p>
  
  <pre><code>service = new ServiceHost(typeof(MyService));
  service.outputMessage += new MyService.MessageEventHandler(frm2_outputMessage);
    // the above line does not work!
  service.Open();
  </code></pre>
  
  <p>(wrapped in a try/catch).</p>
  
  <p>Can anyone help, either by telling me how to get this approach to work or by pointing me at a better way.</p>
  
  <p>TIA</p>