title: "The handle is invalid" error when writing to eventlog using ASP.NET
body: <p>I am working with an ASP.NET 2.0 application (created by my predecessor). Users log into it with AD credentials, and everything done within the app uses those credentials. I modified a page in the application that has nothing to do with event logging, and now my users get this error:
  <img src="https://i.stack.imgur.com/M15CA.png" alt="Handle is invalid error"></p>
  
  <p>Here is the relevant code from the global.asax file: </p>
  
  <pre><code>public void LogException(Exception e)
      {
          string exceptionXml = RenderException(e, true);
  
          _EventLog.WriteEntry("Exception of type " + e.GetType().FullName + " occurred.\n\n" + exceptionXml, EventLogEntryType.Error);
      }
  </code></pre>
  
  <p>RenderException() just puts the exception XML into a flat string, removing white spaces.</p>
  
  <p>I am at a loss on how to get rid of this error. I have tried re-publishing the website with an iisreset. I have tried restarting the web server (2k3 w/ iis 6.0), flushing the app pool. I have also tried modifying the permissions in the registry for the top-level event log key. Can anyone tell me how to get rid of this error? It does not happen on my computer, so it is very hard to replicate. Also, the browser used does not seem to matter. The previous version will work for the same persons getting this error. </p>