Why does MSDN say that it’s rare to load an assembly along the way?

According to the documentation for System.Assembly :

LoadFile and LoadFrom for rare scenarios in which an assembly needs to be identified along the way.

They suggest that you load the assembly more often by its display name (for example, "System.Windows.Forms, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089").

It makes no sense to me. If you want to reference the assembly by its version and public key, you must add the link at compile time; you do not load it at runtime using the Assembly class. A typical scenario for loading the assembly at runtime is when you load the plug-in, which will run along the way - because you either scan the directory for the plug-ins or read some manifest that says where they are located.

Why do the documents say that among the scenarios where you dynamically load the assembly, loading along the path is "rare"? As far as I can tell, it loads it with a display name, which would be rare.

+6
assemblies msdn
source share
3 answers

Well, this should be rare because it is so troublesome. But yes, plugins are usually loaded by LoadFrom (). Never load LoadFile (), which requires real problems.

The problem is that you cannot predict what will happen to the assemblies on which the plugin depends. The right solution to the problem is shit. The solution you must approve is the .config file, so you can use Load (), and the tracking paths are predictable.

+2
source share

I believe that they say that if you specify a path, it will boot from that path, but they would prefer you say "what" you want to download, and let .net runtime download it from where it is " supposed to be based on its rules.

http://msdn.microsoft.com/en-us/library/yx7xezcf%28VS.71%29.aspx

+1
source share

I downloaded the plugins by display name. What for? Well, because, believe it or not, assemblies do not have to live on disk at all (or at least not in a way that gives you a direct path to them). It can be incredibly useful.

In addition, “optional” assemblies, such as serialization assemblies, are usually Assembly.Load ed by name.

+1
source share

All Articles