When the same assembly is found in two separate ways, the AssemblyName differs?

huzaifa sunny 1 Reputation point
2022-08-20T09:41:14.37+00:00

When the same assembly is found in two separate ways, the AssemblyName differs.
I've been investigating assembly versions to tackle assembly binding redirect difficulties in a.NET 4.7.2 app. I've been through hundreds of assemblies by this point, but one, in particular, has been very upsetting. Depending on how I retrieve the AssemblyName, the assembly System.ValueTuple.dll returns a different AssemblyName (particularly the Version changes). The two following methods yield identical AssemblyName objects for the other hundreds of assemblies. The first returns a Version of 4.0.0.0 while the second returns a value of 4.0.3.0 for System.ValueTuple.dll.

GetName();

var assemblyName2 = AssemblyName.GetAssemblyName(filePath); / Method 2

AssemblyName1 and assemblyName2 are both of the same Type, have the same Name, and have the same public key, but their versions differ. This is the first time I've ever seen anything like it.

Does anyone have any idea what's going on here?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,306 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 57,731 Reputation points
    2022-08-22T17:37:07.79+00:00

    nuget packages for 4.7:

    System.ValueTuple: 4.0.3 = dll 4.0.1.0
    System.ValueTuple: 4.0.4 = dll 4.0.2.0
    System.ValueTuple: 4.5.0 = dll 4.0.3.0

    your projects probably use different nuget package versions. as 4.5.0 is the last nuget version (and 4 years old) and not used after core 2.0 (which is unsupported) you should just update the nuget references.

    0 comments No comments