title: CommunicationObjectFaulted when using a NamedPipe WCF service
body: <p>Our .NET app uses 2 AppDomains. The secondary domain needs access to a Logger object that was created in the main appdomain.</p>
  
  <p>This logger is exposed via a WCF service with a named pipe binding.</p>
  
  <p>This is how i create the "client" for this service:</p>
  
  <pre><code>        private void InitLogger()
          {    
              if (loggerProxy != null)
              {
                  Logger.Instance.onLogEvent -= loggerProxy.Log;
              }
  
              // Connect to the logger proxy.
              var ep = new EndpointAddress("net.pipe://localhost/app/log");
              var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
  
              //Logger.Debug("Creating proxy to Logger object.");
              var channelFactory = new ChannelFactory&lt;ILogProvider&gt;(binding, ep);
  
              loggerProxy = channelFactory.CreateChannel();
              channelFactory.Faulted += (sender, args) =&gt; InitLogger();
              channelFactory.Closed += (sender, args) =&gt; InitLogger();
  
              Logger.Instance.onLogEvent += loggerProxy.Log;
          }
  </code></pre>
  
  <p>Recently we are getting random CommunicationObjectFaultedException - i suppose this occurs since the channel times out or due to some other reason that i am missing.</p>
  
  <p>This is the reason i have added the handling of the <em>Closed</em> and <em>Faulted</em> events, which seem to not work properly (perhaps i have not used them appropriately).</p>
  
  <p>EDIT: These events are on the Factory object as suggested, so this explains why they are not being raised.</p>
  
  <p>My question is -- <strong>how can i avoid these errors?</strong></p>
  
  <p>Our scenario is we need to keep this channel open at all times throughout the application's lifetime, and the access to this Logger service is needed at all times, and shouldn't time out under any circumstance.</p>
  
  <p>Is there any safe practice of handling this type of situation?</p>