0

I have an ASP.NET Core application that uses Microsoft.AspNetCore version 2.2.0 library. This library uses System.Text.Encoding.Web version 4.5.0 library internally. We need to upgrade the application to use at least System.Text.Encoding.Web version 4.5.1 library due to security issues.

How can this be done in a .NET Core application?

We could do this easily in a .NET application, by using AssemblyRedirect properties in the web.config file.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ajit Goel
  • 4,180
  • 7
  • 59
  • 107
  • Binding redirects are a .NET framework concept, there are no binding redirects on .NET Standard and .NET Core.A detailed explanation is given [in this link](https://stackoverflow.com/questions/46111749/adding-a-bindingredirect-to-a-net-standard-library?answertab=votes#tab-top), you can check it out. – Yihui Sun Jun 30 '21 at 02:37

1 Answers1

1

As mentioned in the comments, there is no binding redirects in .NET Core. Dynamic linking are resolved at runtime and is controlled by the .deps.json manifest file which is usually generated by the compiler during compilation.

One way to achieve what you want is to simply reference System.Text.Encodings.Web 4.5.1 directly in your source project. This will override any transitive reference to System.Text.Encodings.Web via the ASP.NET Core framework:

<ItemGroup>
  <PackageReference Include="System.Text.Encodings.Web" Version="4.5.1" />
  <PackageReference Include="Microsoft.AspNetCore.App" />
  ...other dependencies
</ItemGroup>

Rebuild the code and the compiler will now generate the correct .deps.json file so that your program will load the new version of System.Text.Encodings.Web at runtime.

scharnyw
  • 2,347
  • 2
  • 18
  • 32