Search code examples
asp.netelmaherror-logging

Could not load type 'Elmah.ErrorLogModule' from assembly 'Elmah'


I have basically loaded Elmah assemblies and installed the package using the NuGet plug-in. I remember it working with one of my project but suddenly it stopped working with

"Could not load type 'Elmah.ErrorLogModule' from assembly 'Elmah'."

error and that is weird. It used to work. Anyways I did not find many solutions to it on Google but I think people have faced this problem before. some suggested it is 32 bit 64 bit version issue.

Any suggestions?


Solution

  • This can happen if Elmah was added manually before and the assembly binding in the web.config references a specific version:

    This -

    <modules>
        <add name="ErrorMail" preCondition="managedHandler" type="Elmah.ErrorMailModule, Elmah-1.1"/>
        <add name="ErrorLog" preCondition="managedHandler" type="Elmah.ErrorLogModule, Elmah-1.1"/>
        <add name="ErrorFilter" preCondition="managedHandler" type="Elmah.ErrorFilterModule, Elmah-1.1"/>
    </modules>
    

    Should be this -

    <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>