none
No way to resolve conflict between log4net

    Question

  • hi,

    I am cough in front of a problem I have tried a lot to find the solution, but no luck. On build, I keep getting the error

    "1>  No way to resolve conflict between "log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" and "log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304". Choosing "log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" arbitrarily.

    1>  No way to resolve conflict between "log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" and "log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821". Choosing "log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" arbitrarily."

    After looking for a solution, as suggested, I have tried to redirect to the new version in the web.config file no luck.

    When trying to re-install the nuget package, error "An item with the same key has already been added", and at the same time, I could not find any references of the dll, nor the key. 

    I have cleaned and rebuild my solution several times. I even have added the dlls in a directory and redirected there from the web.config.

    Could you please help me out with this? 


    newbie

    Wednesday, April 19, 2017 1:42 PM

All replies

  • This looks like a compiler warning and not a runtime error. Compiler warnings cannot be resolved by web.config changes. The issue is that you have multiple projects referencing different versions of log4net. You need to ensure that all your projects are using the same version. You can use Manage Packe for Solution to see the packages for all the projects you have loaded. You should consolidate any that are using older versions to the newer version.

    If you are unable to figure out where the reference is coming from then: a) look in Packages.config or b) turn on detail build output and it'll print the conflicting assemblies in the build output.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, April 19, 2017 2:09 PM
    Moderator
  • Thank you for your advice,

    Unfortunately, I am not using log4net in any of my projects, but I can assume a couple of my packages are... I have found which packages using the log4net (by trial and error in addition to some common sense), and those are references I really need to make my system work as it should (one of them is crystal reports). 

    When I try to update the packages, I get an error : "An item with the same key has already been added". Is there a way I can manually remove all references of those packages so I can try installing them again? since simply by removing it from the list won't do it. or if you have any other suggestions would be great. 


    newbie

    Friday, April 21, 2017 1:23 PM
  • You should be able to go to Manage Packages for Solution, go to the Consolidate tab and consolidate them. It shouldn't generate any errors. If it does then ensure you're using the latest version of the NuGet Package Manager. If it does generate an error then read the error carefully. It is possible one of the packages you're using has a hard dependency on the version of log4net. If that is the case then there isn't much you can do about it other than contacting the package provider to get an updated version.

    If that doesn't resolve your problem then go to your main executable's packages and add NuGet to the list. This will at least ensure the runtime is using the correct version as a binding redirect will be added to the config.

    If that still doesn't work then you can do it manually but it could break things.

    1. Open the packages.config for each project using the older version.
    2. Change the version number (and possibly target framework) to match the newer version.
    3. Open the project file in a text editor.
    4. Find the reference to the package in the packages folder.
    5. Update the version number so the path is correct.

    After doing all that, delete the entire packages folder and do a clean build.

    Friday, April 21, 2017 1:37 PM
    Moderator