16

I'm trying to get Elmah working under ASP.NET MVC and I thought I had. I used the very convenient Elmah MVC project which automatically setup my web.config file. Now if I run the project under IIS Express then Elmah works just perfectly. I can access it with the correct Authorisation and the logs are stored in my SQL Database. However when I try and run it under IIS 7.5 I get an:

An HTTP 500.19 Internal Server error 
Module  IIS Web Core
Notification    BeginRequest
Handler Not yet determined
Error Code  0x800700b7
Config Error    Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'ErrorLog'
Config File web.config

Config Source:
  111:     <modules>
  112:       <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  113:     </modules>

I'm baffled as to why this might be. As a test I've created a brand new clean MVC project and it reacts exactly the same way.

Chris Nevill
  • 5,922
  • 11
  • 44
  • 79
  • 1
    try to do a before the – rene Jul 29 '13 at 15:57
  • Amazing. I've no idea why I've had to do that as ErrorLog isn't elsewhere but it's worked. I actually had to do it on the three following entries as well but Elmah is working! Thanks Rene – Chris Nevill Jul 29 '13 at 16:06

1 Answers1

21

do a

<remove name="ErrorLog"/>

before the

<add />

to get rid of any default defined entries named ErrorLog in the modules section of your web.config file.

rene
  • 41,474
  • 78
  • 114
  • 152
  • Do you know why this fixes the problem? – Arminder Dahul Jun 18 '15 at 08:26
  • 1
    @ArminderDahul Yes, either a [machine.config or web.config](https://msdn.microsoft.com/en-us/library/1xtk877y(v=vs.100).aspx) in the folder hierarchy for the running appdomain has a module already added named ErrorLog. The elmah installer seems to have a batch file that makes those changes for you will adding the assemblies to the GAC. – rene Jun 18 '15 at 14:17