ASP.NET Troubleshooting

You are probably here because your application doesn't log errors to elmah.io, even though you installed the integration. Before contacting support, there are some things you can try out yourself.

  • Make sure that you are referencing one of the following NuGet packages: Elmah.Io, Elmah.Io.AspNet, Elmah.Io.Mvc or Elmah.Io.WebApi.
  • Make sure that the Elmah.Io.Client NuGet package is installed and that the major version matches that of Elmah.Io, Elmah.Io.AspNet, Elmah.Io.Mvc or Elmah.Io.WebApi.
  • Make sure that your project reference the following assemblies: Elmah, Elmah.Io, and Elmah.Io.Client.
  • Make sure that your web.config file contains valid config as described here. You can validate your web.config file using this Web.config Validator. When installing the Elmah.Io NuGet package, config is automatically added to your web.config file, as long as your Visual Studio allows for running PowerShell scripts as part of the installation. To check if you have the correct execution policy, go to the Package Manager Console and verify that the result of the follow statement is RemoteSigned: Get-ExecutionPolicy
  • Make sure that your server has an outgoing internet connection and that it can communicate with api.elmah.io on port 443. Most of our integrations support setting up an HTTP proxy if your server doesn't allow outgoing traffic.
  • Make sure that you didn't enable any Ignore filters or set up any Rules with an ignore action on the log in question.
  • Make sure that you don't have any code catching all exceptions happening in your system and ignoring them (could be a logging filter or similar).
  • If you are using custom errors, make sure to configure it correctly. For more details, check out the following posts: Web.config customErrors element with ASP.NET explained and Demystifying ASP.NET MVC 5 Error Pages and Error Logging.

Common exceptions and how to fix them

Here you will a list of common exceptions and how to solve them.

TypeLoadException

Exception

[TypeLoadException: Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible.]
   Microsoft.Rest.ServiceClient`1.CreateRootHandler() +0
   Microsoft.Rest.ServiceClient`1..ctor(DelegatingHandler[] handlers) +59
   Elmah.Io.Client.ElmahioAPI..ctor(DelegatingHandler[] handlers) +96
   Elmah.Io.Client.ElmahioAPI..ctor(ServiceClientCredentials credentials, DelegatingHandler[] handlers) +70
   Elmah.Io.Client.ElmahioAPI.Create(String apiKey, ElmahIoOptions options) +146
   Elmah.Io.Client.ElmahioAPI.Create(String apiKey) +91
   Elmah.Io.ErrorLog..ctor(IDictionary config) +109

Solution

This is most likely caused by a problem with the System.Net.Http NuGet package. Make sure to upgrade to the newest version (4.3.4 as of writing this). The default template for creating a new web application, installs version 4.3.0 which is seriously flawed.


This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website