Is it possible to use binding redirects to replace a nuget package assembly with a custom debug replacement for testing?


In my particular case we're using the RabbitMQ client package from NuGet and having some issues with it's auto-recovery. I want to add some additional logging within the implementation, so I took the source for the version we're using, added a few lines of log messages and built it. Ideally I'd be able to put the assembly in place on our test machine that's reproducing the issue, put in a temporary binding redirect and call it a day. But as far as I can tell it's ignoring the redirect:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="RabbitMQ.Client" publicKeyToken=null culture="neutral"/>
        <bindingRedirect oldVersion="" newVersion=""/>

Here's the error message I get when I try to run it:

.\ClientAgent.Service.exe :
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Unhandled Exception:

System.IO.FileLoadException: Could not load file or assembly 'RabbitMQ.Client, Version=, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce' or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at ClientAgent.Service.RabbitMqNLogEventListener..ctor()
   at ClientAgent.Service.ClientAgentProgram.Main()

Note that it's still referencing the PublicKeyToken of 89e7d7c5feba84ce.

  • Is this likely due to strong naming, or would the error be more specific in that case?
  • Is this possible at all, or is there a better way to accomplish this goal?
  • I could rebuild my agent pointed at this dll, but we have half a dozen or more internal libraries it uses that also rely on the rabbit package and I assume I'd have to update all their references to the locally built dll by hand.
asked on Stack Overflow May 27, 2020 by MichaC

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0