devoured elysium
devoured elysium

Reputation: 105097

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

Thanks

Upvotes: 4

Views: 198

Answers (3)

Venemo
Venemo

Reputation: 19077

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

Upvotes: 1

Lex Li
Lex Li

Reputation: 63203

You may start to learn about .NET versioning,

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

Upvotes: 3

TomTom
TomTom

Reputation: 62101

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.

Upvotes: 1

Related Questions