There is a way to do this at runtime. Add the following code to your Main or ConfigureServices (asp.net) or wherever, just make sure it's before the assembly is tried to be loaded from you application.
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
if (args.Name.Contains("IdentityModel") && args.Name.Contains("PublicKeyToken=e7877f4675df049f"))
{
string assemblyPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "IdentityModel.dll");
if (System.IO.File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
}
return null;
};
At runtime args.Name
contains this format: IdentityModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=e7877f4675df049f
Make sure the dll is present in the bin folder (or any other place you define yourself). Just adding the nuget PackageReference with specific version should be enough.
You can doublecheck the bin folder if the dll is the version you are expecting if you are experiencing issues with this solution.
app.config
and add a binding redirect. – Genitourinaryapp.config
is default included in .net framework templates, but is missing in the .net core templates. Whilst OP indicates to have knowledge about theapp.config
, it's still ambiguous if OP knows he/she can just add the file. – Genitourinary