How do I compare two AssemblyName instances to figure out whether they represent the same assembly? The 'Equals' method isn't overriden.
One way I can think of is compare the 'ToString()' results of both the instances but I would prefer an 'Equals' syntax since I need to prepare a list (List) of 'unique' AssemblyName instances and would like to use the 'Contains(AssemblyName item)' method.
As long as you are using strongly-named assemblies, comparing the output of the ToString method would be fine, as it outputs the full name of the assembly, which is supposed to be consistent and seems to be culture-invariant.
If the assemblies are not strong-named, then one can easily create another assembly with the same name and version number/culture and it would have the same assembly name as yours.
One thing to note though, because the assembly names are the same doesn't mean that the assemblies are the same physical identity; location is not part of the assembly name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With