11

I'm using a web deployment project and want to do some section replacement with the emlah/errorMail section. I don't want to send emails in debug build mode.

I have created the custom section and put it in an errorMail.config. In the properties of web deploy project under replacements, I have elmah/errorMail=errorMail.config.

The error I'm getting is An error occurred creating the configuration section handler for elmah/errorMail: Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified.

I'm guessing this is happening because Elmah is not in the GAC or it's not one of my projects. The Elmah.dll file does copy to the output\bin folder just fine though.

Is there a way to have section replacements work with 3rd party dlls?

[EDIT]

I found that if I drop the dll in question into the project folder for the web deployment project, that it will work fine. This is less than optimal.

So now my question is, how can I get this to work without having to put the dll in the GAC or having to copy the dll into the web deployment project folder?

Josh Close
  • 22,935
  • 13
  • 92
  • 140
  • Very annoying problem which should have been fixed by MS. I have encountered it with elmah and nlog now. I'll use your deployment project folder fix for now. Thanks. – UpTheCreek May 17 '11 at 15:44
  • Strange - having the dll in the deployment project folder does not work for me :/ – UpTheCreek May 17 '11 at 15:47

2 Answers2

1

If you add a reference to the elmah dll from your webproject, then it will automatically copy the dll to the output folder when you build it.

Those are the only 2 options though: to have the dll copied to the output directory or to put it in the GAC

Matthew Steeples
  • 7,858
  • 4
  • 34
  • 49
  • Check in your web.config file whether you are referring to a specific version or not and that the version you are including matches that – Matthew Steeples May 17 '11 at 16:26
  • There are no particular versions specified in the web.config for either of the dlls that are causing problems I'm afraid :/ – UpTheCreek May 17 '11 at 17:07
  • Actually GAC is not an option either, as ELMAH is not a strong-named assembly, so you can't add it! – UpTheCreek May 17 '11 at 18:04
  • 1
    The source is available so you can strongly sign it yourself to put it in the GAC. If you want a hand diagnosing this then I'm happy to help you out in a chat.stackoverflow.com room. – Matthew Steeples May 17 '11 at 18:09
0

A technique proposed here dynamically loads an assembly during the web deployment build process so that it doesn't have to be in the GAC. I tried, but was unable to get it to work, though.

user281806
  • 1,020
  • 9
  • 14
  • I tried this, but it didn't work for me either. The new task itself reported that it couldn't find the problematic assembly. – UpTheCreek May 17 '11 at 18:45