views:

94

answers:

4

After reading through the MSDN article How the Runtime Locates Assemblies and also reading this, I am still unsure about how weakly named assemblies are resolved at runtime.

Eg. if I have a reference to some dll file in my project, I compile and deploy, will it pick up a new version of the referenced dll file if I just replace the old one which was actually referenced at compile time? Does it matter if the reference in the project file specifies the version etc. of the referenced assembly?

Any enlightenment welcome

A: 

The answer to your questions is yes as long as long as you have Specific Version set to False in the properties for the reference to the assembly.

Daniel Earwicker
This is not correct, it only applies at compile time.
Hans Passant
+1  A: 

The best place that I've found to learn about this is in Grimes Fusion Workshop as can be found here. It is very comprehensive while still easy to understand.

ho1
A: 

If version is not mentioned it will pick up the reference, if the version is mentioned it will try to find and load the assembly matching the signature with version mentioned. if not found it will throw an exception. To resolve this you can do assembly binding redirection.

this. __curious_geek
+1  A: 

If the assembly is not found in the GAC then the CLR will search for it in the "probing path". Which by default is only the directory that contains the EXE. It only looks for a match on the assembly name and will stop searching on the first match.

It then checks the [AssemblyVersion] number. If it doesn't match you'll get an exception, it won't keep looking for another assembly with the same name. Whenever you have resolution trouble, you'll want to use the Fuslogvw.exe utility. It shows you exactly where the CLR looked and what went wrong.

Hans Passant
Do weak references bother with the version number? My experience is that it just matches by name if you are in the probing path (not sure about GAC, but then it wouldn't be weak).
Adam
Whether it is strong named or not doesn't matter. Only the GAC is capable of resolving a referenced assembly by version number. Probing path searches are only done by name, the version number is still checked after an assembly was found.
Hans Passant