How does AssemblyName.ReferenceMatchesDefinition work?

Posted by Fabian Schmied on Stack Overflow See other posts from Stack Overflow or by Fabian Schmied
Published on 2010-03-22T17:36:29Z Indexed on 2010/03/22 17:41 UTC
Read the original article Hit count: 283

Given the following code:

  var n1 = new AssemblyName ("TestDll, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
  var n2 = new AssemblyName ("TestDll, Version=2.0.0.2001, Culture=en-US, PublicKeyToken=ab7a5c561934e089");

  Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n1, n2));
  Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n2, n1));

Why do both of these checks print "True"? I would have thought that AssemblyName.ReferenceMatchesDefinition should consider differences in the version, culture, and public key token attributes of an assembly name, shouldn't they?

If not, what does ReferenceMatchesDefinition do that a comparison of the simple names doesn't?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection