How does the CLR know which if the given assembly is the correct one?
If we have a .NET executable that's using a .NET library, how does the CLR ensure you are using the correct version of the dll? CLRwise what is considered be the "correct dll version", to start with?
Does it only look at the version? Looks also at t开发者_Go百科he build-time(?). Maybe it looks at an hash or something?
Thanks
You may start to learn about .NET versioning,
http://msdn.microsoft.com/en-us/library/51ket42z(VS.71).aspx
It takes the one used during compile, identified by fully qualified name - which includes not only the assembly name, but also the complete version information AND the digital signature fingerprint if one was available.
The other answers already cover the essence of it.
Basically, the Framework checks for assembly name, version, and signature of an assembly to find a match.
The name and version (and more stuff!) you can set from code (AssemblyVersion attributes), and you can easily sign it with the help of VS, too.
The signature involves creating a .pfx file (VS will generate one for you), and checking the "sign assembly" in the build settings. This will ensure that more than one assemblies can coexist with the same name and version.
(So if two companies accidentally created two things with the same name, you can still use them together.)
精彩评论