title: Elmah for non-HTTP protocol applications OR Elmah without HttpContext
body: <p>We are working on a 3-tier application, and we've been allowed to use the latest and greatest (MVC2, IIS7.5, WCF, SQL2k8, etc).  The application tier is exposed to the various web applications by WCF services.  Since we control both the service and client side, we've  decided to use net.tcp bindings for their performance advantage over HTTP.</p>
  
  <p>We would like to use <a href="http://code.google.com/p/elmah/" rel="nofollow noreferrer">ELMAH</a> for the error logging, both on the web apps and services. Here's my question. There's lots of information about using ELMAH with WCF, but it is all for HTTP bindings.  Does anyone know if/how you can use ELMAH with WCF services exposing non-HTTP endpoints?</p>
  
  <p>My guess is no, because ELMAH wants the HttpContext, which requires the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehostingenvironment.aspnetcompatibilityenabled.aspx" rel="nofollow noreferrer">AspNetCompatibilityEnabled</a> flag to be true in the web.config.  From <a href="http://msdn.microsoft.com/en-us/library/aa702682.aspx#sectionSection1" rel="nofollow noreferrer">MSDN</a>:</p>
  
  <blockquote>
    <p>IIS 7.0 and WAS allows WCF services to communicate over protocols other than HTTP. However, WCF services running in applications that have enabled ASP.NET compatibility mode are not permitted to expose non-HTTP endpoints. Such a configuration generates an activation exception when the service receives its first message.</p>
  </blockquote>
  
  <p>If it is true that you cannot use ELMAH with WCF services having non-HTTP endpoints, then the follow-up question is: Can we use ELMAH in such a way that doesn't need HttpContext?
  Or more generally (so as not to commit the <a href="http://blogs.msdn.com/ericlippert/archive/2003/11/03/a-parable.aspx" rel="nofollow noreferrer">thin metal ruler</a> error), is there ANY way to use ELMAH with WCF services having non-HTTP endpoints?</p>
  
  <p><strong>Note:</strong> I'm aware that we can download the Elmah source code and change it to add a shim or remove the HttpContext dependency, but I'm trying to avoid forking the code.</p>