Compile C # library projects requiring bindingRedirect

I refer to a third-party dll that requires a Redirect binding in the app.config file as follows:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.10.0" newVersion="2.1.10.0" />
      </dependentAssembly>
      ...
    </assemblyBinding>
</runtime>

I am trying to reference this in a C # library project. The library will be shared by the WCF project and the MVC project. However, my library can no longer find the links. I get the following warning:

The main link "ThirdParty" cannot be resolved because it has an indirect dependence on the assembly of the system "System.Net.Http, Version = 1.5.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" which cannot be resolved within the target framework. ".NETFramework, Version = v4.0". To fix this problem, remove the "ThirdParty" link or redirect the application to a structure that contains "System.Net.Http, Version = 1.5.0.0, Culture = Neutral, PublicKeyToken = b03f5f7f11d50a3a"

I added the app.config file to the library with the required bindingRedirect. However, this configuration is ignored.

I also tried to convert the library to a console application. In this case, it compiles and works fine.

, bindBinding bindRedirect?

+4
1

, DLL System.Net.Http. System.Net.Http .

, Nuget. Microsoft HTTP.

+2

Source: https://habr.com/ru/post/1531752/


All Articles