Search code examples
asp.netelmahdll

How can I deploy two different versions of the same managed asp.net dll to production? Or... how better do I get around this?


Here's the problem. I've got two different technologies needing drivers to access a PostgreSQL database.

  1. Telerik Open Access ORM (2011.2.x)
  2. Elmah (latest as of writing this question)

Both use the Npgsql driver , however, both AFAIK use two different versions of the driver.

  • Elmah: Npgsql 2.0.6.0
  • Open Access: Npgsql 2.0.10.0 (I'm not sure how it loads the DLL, but this is the one shipped with what I'm using currently)

and also:

  • both drivers seem to be using the same version, at least in number, of Mono.Security.dll 2.0.0.0

Right now, I've got my local project running, and it appears to be working on both fronts, that is Open Access is using it's driver (likely From the GAC as I've installed on my work machine from Telerik the installer, but the project never referenced the PostgreSQL drivers), and Elmah is working with it's driver (referenced in the project). It's conceivable that Telerik may actually be using the Npgsql driver in the project instead, but I'm not sure how to verify that possiblility.

However, in production I don't have the Telerik drivers loaded in the GAC, I have all my dlls placed in the website's bin folder. Both dlls are named the same, and renaming the older driver doesn't work locally.

So I'm wondering what I ought to do at this point.

Elmah is an open source source project, so I know I can get the source to it (instead of using the NuGet package) and modify it to reference the newer driver. But frankly I don't want to have to deal with recompiling Elmah if I want to update Telerik.

I'm wondering if the problem may just be that the latest Elmah is linked to the driver in a far stricter fashion than it needs to be? I've read about the various forms of linking, but not enough to know what I"m talking about. If that's the case, though, it might be better to compile it such that (maybe) it only needs 2.0.x or something and use whatever is available instead of using some absolute version.

Is that possible? Is there another, better way to handle this? Thanks.


Solution

  • While I did use the Nuget packages to install the elmah core libraries and the PostSQL drivers, I ended up removing the reference to Npgsql in the project and added the following lines to the web config under the configuration/runtime/assemblyBinding element:

            <dependentAssembly>
                <assemblyIdentity name="Npgsql"
                                  publicKeyToken="5d8b90d52f46fda7"
                                  culture="neutral" />
                <bindingRedirect oldVersion="2.0.6.0"
                                 newVersion="2.0.10.0"/>
            </dependentAssembly>
    

    Seems to work pretty well. The assumption, of course, is that the new driver is backwards compatible with the old one. No codeBase or ILMerge mess.