This article is a mirror article of machine translation, please click here to jump to the original article.

View: 30883|Reply: 1

[Source] .net/c# reference dll version conflict resolution

[Copy link]
Posted on 6/4/2018 4:02:54 PM | | | |
Failed to load the file or assembly "Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" or one of its dependencies. The found assembly manifest definition does not match the assembly reference. (Exception from HRESULT:0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Check the stack trace information for details about the error and where it came from in your code that caused the error.

Exception details: System.IO.FileLoadException: Failed to load file or assembly "Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" or one of its dependencies. The found assembly manifest definition does not match the assembly reference. (Exception from HRESULT:0x80131040)

Source error:

An unhandled exception was generated during the execution of the current web request. You can use the following exception stack trace information to determine the cause of the anomaly and where it occurred.

Assembly Load Trace: The following information can help determine why the assembly "Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" failed to load.


Sometimes, we see the above error.

Error cause

Project A references xxx.dll, Project B also references xxx.dll, and Project A refers to Project B, as shown in the figure below:



Both project A and project B refer to xxx.dll, but project A refers to a higher version of the dll, and project B refers to a lower version of the dll

Solution

<bindingRedirect>element, redirect one assembly version to another.

oldVersion       

  • Required properties
  • Specifies the version of the assembly that was originally requested. The assembly version number is in the format of major.minor.build.revision. Each part of this version number has a valid value between 0 and 65535.
  • You can also specify a version range in the following format:
  • n.n.n.n-n.n.n.n



newVersion

  • Required properties.
  • Specifies the version of the assembly to use instead of the version format originally requested: n.n.n.n
  • This value can specify a version prior to oldVersion.



Documentation link:https://docs.microsoft.com/zh-cn ... ingredirect-element

Official examples:



So, my workaround is to set it up like this in web.config:







Previous:I'm here, please pay more attention and learn from each other
Next:Solution: The installer used to install Visual Studio is incomplete
 Landlord| Posted on 10/22/2022 10:03:58 AM |
[Practical Operation] Conflicts between referring to different versions of DLLs that rely on redirects
https://www.itsvse.com/thread-10376-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com