Search code examples
nugetlinqpadassembly-binding-redirect

In LINQPad, if a nuget package references another nuget package that has a vulnerability, how to do equivalent of binding redirect


I have a LINQPad script, using C# and referencing a nuget library Contrast.Rest.Client. The nuget manager warns me that Contrast.Rest.Client depends on a vulnerable version of Newtonsoft.Json. I've notified the nuget publisher but until they fix it, can I change which version of Newtonsoft.Json is used?

I saw in the comments to this that LINQPad has its own resolution mechanism. Does that affect my question?


Solution

  • Per [this comment] from @Joe-Albahari on the LINQPad forum:

    Presumably you're using LINQPad 5? Does it help if you add explicit references to the latest versions of the System.Runtime.CompilerServices.Unsafe and System.Memory, either directly to the query or to your library (in the same folder)? This should make LINQPad generate binding redirects.

    This did work for me. Adding a nuget reference to the latest version of Newtonsoft.Json suppressed the vulnerability warning.