tags:

views:

72

answers:

3

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 the build-time(?). Maybe it looks at an hash or something?

Thanks

+1  A: 

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.

TomTom
Could you explain a little better that digital signature thing? How and when is it done? Also, let's assume I create a Hello world application and build it 10 times. Will the output .exe be any different if I don't change its code? Will the version change?
devoured elysium
Read any introduction into .NET - "code signing" is the topic you want. If oyu need the basics, nothing beats reading the documentation.
TomTom
+3  A: 

You may start to learn about .NET versioning,

http://msdn.microsoft.com/en-us/library/51ket42z(VS.71).aspx

Lex Li
+1  A: 

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.)

Venemo