Search code examples
.netcrystal-reportslog4netclickonce.net-assembly

ClickOnce / Assembly binding redirect not working for Log4Net.DLL


I have been at this for the second day now, and I am almost giving up. I have read many threads related to different libraries having dependencies to different Log4Net.dll versions, ClickOnce deployment, and Assembly binding redirection, and none of the answers/suggestions I have found so far works for me. Hopefully someone here will be able to shed a light :)

The problem I am trying to solve:

We have an internal winforms application .NET 4.0, that uses Crystal Reports, and that we deploy it using ClickOnce.

I had to do some major refactor, and introduced Log4Net to one of the modules, specifically the one which also uses Crystal reports. Everything worked fine on my development machine, as always, and upon deploying to a test machine where Crystal is not installed (or with Crystal installed for that matter -- just different errors will occur), the install fails at different points - either right before it starts downloading or right at the point where it tries to download the Log4Net.dll (see pics below).

The culprit of my problem is that Crystal reports uses (for some crazy reason that I haven't been able to find) an earlier version of Log4Net.dll (1.2.10.0) and the version I am using is 1.2.13.0.

The approaches I have tried and have not worked:

I have tried many things, which I lost count already, but I will try to outline some of the major approaches I took and maybe someone can see where I failed:

  • Upgraded to the latest version of Crystal Reports for .NET
  • Added both versions of Log4Net.dll to the project (different folders in project), and use custom assembly from this post: Using different versions of the same assembly in the same folder
  • Assembly binding redirection (latest)

My project setup:

From a logical stand point, I believe (and might be wrong) that the correct approach in this case, should be to use Assembly binding redirection to have Crystal use the latest Log4Net.dll but something is not working with my setup, and I am not sure what.

- References:

enter image description here

enter image description here

enter image description here

- Binding redirect

This is the current setting

One thing to know here is that, the publicKeyToken for the 1.2.13.0 version is different from the 1.2.10.0 and the publicKeyToken listed in the assemblyIdentity here is the one for the 1.2.10.0 version.

I tried this as well enter image description here

- Publish Settings and Install Errors:

With the Include (auto) option, the installer can't seem to find the DLL: enter image description here

enter image description here

With the Include (forced include) option, the installer is trying to download the DLL twice, or so it seems:

enter image description here

enter image description here


Solution

  • You can't do a redirect to a version with a different key, and the key changed in 1.2.11

    But, you can get a version of log4net 1.2.13 signed with the old key from NuGet, which will help the redirect to work.