Installing Elmah in the GAC

۲۵۵ بازدید
رفتن به اولین پیام خوانده‌نشده

Bart Hermans

خوانده‌نشده،
۱۲ آذر ۱۳۸۷، ۹:۰۶:۰۴۱۳۸۷/۹/۱۲
به ELMAH
Hi,

While trying to install Elmah in the GAC, I kept getting errors that
the dll could not be found.
I found a solution to my problem and wanted to post it here, so others
can benefit from it.

Steps to take:
- Open the source code in Visual Studio
- Go to the Project settings, Signing, and add a new key file, name it
whatever you want
- Build the project
- Open a Visual Studio command prompt and navigate to the folder that
contains the newly compiled elmah.dll
- Install the dll in the GAC: gacutil -i elmah.dll
- Open web.config in C:\WINDOWS\Microsoft.NET\Framework
\v2.0.50727\CONFIG
- Add the following line to the <assemblies> section:
<add assembly="Elmah, Version=1.0.10617.0, Culture=neutral,
PublicKeyToken=2639751d020a1974"/>
(The PublicKeyToken may be different on your pc, not sure about that
(can anyone comment on this?), check the properties of elmah.dll in c:
\windows\assembly)
- Add the following line to the <httpHandlers> section, make sure it
is on top!
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory"/>
- Add the following line to the <httpModules> section:
<add name="ErrorLog" type="Elmah.ErrorLogModule"/>

That's about it, you should now be able to go to http://url_to_application/elmah.axd

Bart

Atif Aziz

خوانده‌نشده،
۱۲ آذر ۱۳۸۷، ۹:۴۲:۲۸۱۳۸۷/۹/۱۲
به el...@googlegroups.com
Thanks for sharing your solution, Bart.

Here are a few notes to complement your post:

> - Install the dll in the GAC: gacutil -i elmah.dll

GACUTIL is an SDK tool so just bear in mind that it will not be available on most production systems where only the .NET Framework runtime will be installed. The officially MS-support way to get a signed assembly into the GAC is via an installer like MSI. The unofficial way in production without GACUTIL would be to open %SystemRoot%\assembly in Windows Explorer and then dragging and dropping the ELMAH assembly into it.

> - Add the following line to the <assemblies> section:
> <add assembly="Elmah, Version=1.0.10617.0, Culture=neutral,
> PublicKeyToken=2639751d020a1974"/>

This step is unnecessary and only works for ASP.NET 2.0 or later. It also only work for code that internally calls ASP.NET's BuildManager.GetType instead of Type.GetType from the system. For sake of compatibility across all .NET Framework versions, ELMAH, for example, uses Type.GetType and not BuildManager.GetType.

> - Add the following line to the <httpHandlers> section,
> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory"/>

Given the public key token you mentioned, this line should read:
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah, Version=1.0.10617.0, Culture=neutral, PublicKeyToken=2639751d020a1974"/>

Make sure the value of the type attribute is not "wrapped". It should be on one line without any CR/LF that e-mail systems may add in re-formatting this message. The .NET Framework is very particular about that.

> - Add the following line to the <httpModules> section:
> <add name="ErrorLog" type="Elmah.ErrorLogModule"/>

Given the public key token you mentioned above, this line should read:
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah, Version=1.0.10617.0, Culture=neutral, PublicKeyToken=2639751d020a1974"/>

Again, make sure the value of the type attribute is not "wrapped".

If you mention the strong name of the assembly as part of each type then the entry in the <assemblies> section is not needed. Yes, it makes the type name very long and ugly but I didn't invent the system. :)

> (The PublicKeyToken may be different on your pc, not sure about that
> (can anyone comment on this?)

The public key token will be different for everyone who generate a new one via Visual Studio or SN.EXE (Strong Name Utility).

Hope this helps,
- Atif

Bart Hermans

خوانده‌نشده،
۱۲ آذر ۱۳۸۷، ۱۰:۰۹:۱۳۱۳۸۷/۹/۱۲
به el...@googlegroups.com
Atif, thank you for your comments.
I tried your solution and it works.
Actually, I spent several hours today getting mine to work, accompanied with a lot of banging my head against the desk... :)

Wouldn't it be useful to post this information on the website? The solution I described, is partly explained in the DotNetSlackers article, but if you follow those instructions, you will not get it to work.

Bart

Atif Aziz

خوانده‌نشده،
۱۲ آذر ۱۳۸۷، ۱۰:۵۸:۳۹۱۳۸۷/۹/۱۲
به el...@googlegroups.com
> Actually, I spent several hours today getting mine to work,
> accompanied with a lot of banging my head against the desk... :)

So that's what that banging sound I heard was. :)

> Wouldn't it be useful to post this information on the website?

I'm not so sure because the steps to sign ELMAH and specify its strong name in configuration are not any different than they would be for any assembly and those steps are very well covered in the MSDN documentation. See:

- How to: Sign an Assembly (Visual Studio):
http://msdn.microsoft.com/en-us/library/ms247123.aspx

- How to: Create a Public/Private Key Pair
http://msdn.microsoft.com/en-us/library/6f05ezxy.aspx

In any event, I've logged this as an issue:
http://code.google.com/p/elmah/issues/detail?id=79
You can *star* it to receive notifications.

Meanwhile, this thread will serve as good food for the search engines.

- Atif
پاسخ به همه
پاسخ به نویسنده
فرستادن
0 پیام جدید