title: How to handle low level WCF errors?
body: <p>I have the standard error handing in place in my service:</p>
  
  <ul>
  <li>I have an IErrorHandler hooked to the service to handle unexpected errors during service execution.</li>
  <li>I have try/catch blocks in all my service methods to handle expected cases.</li>
  </ul>
  
  <p>However, there are cases where exceptions are thrown on the server and neither is called.</p>
  
  <p>Here is a case where the server exception is not sent to the IErrorHandler: </p>
  
  <ul>
  <li><p>Set the receiveTimout on the server binding to 5 seconds.</p></li>
  <li><p>On the client do this:</p></li>
  </ul>
  
  <p>.</p>
  
  <pre><code>Service1Client sc = new Service1Client();
  ICommunicationObject o = sc as ICommunicationObject;
  
  o.Open(); // open channel
  
  sc.GetData(10); // do a first call
  
  Thread.Sleep(10000); // wait longer than the server receiveTimeout
  
  sc.GetData(10); // Attempt another call: server throws a FaulException
  </code></pre>
  
  <p>In that case, the error is thrown on the server but I cannot find a way to handle it (and log it). I know an error is raised because if I attach a debugger on the server process and break on all exceptions, the debugger breaks. </p>
  
  <p>I have found other similar cases where low level errors are not passed to my program.</p>
  
  <p>Where can I hook my code to ensure that I can handle ALL exceptions that occur on the server before they are returned to the client app? Should I implement my own IChannel or some other low level interface?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE Sep 21 2009</strong>: See <a href="http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/21b77052-2b6e-439c-80b6-83607393edb2" rel="noreferrer">this</a> thread on the Microsoft WCF Forum. I'll probably have to implement my own Channel if I want to handle this type of exception. I'll update this post again when I have more info.</p>