Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is actually a lot of discussion about this, with some differing opinions:</p> <p><a href="https://stackoverflow.com/questions/1477843/difference-between-loadfile-and-loadfrom-with-net-assemblies">Difference between LoadFile and LoadFrom with .NET Assemblies?</a></p> <p><a href="http://geekswithblogs.net/rupreet/archive/2010/02/16/137988.aspx" rel="nofollow noreferrer">http://geekswithblogs.net/rupreet/archive/2010/02/16/137988.aspx</a></p> <p><a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/3bdaf65c-520c-4a1a-a825-fc2ca2957bf3" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/3bdaf65c-520c-4a1a-a825-fc2ca2957bf3</a></p> <p><a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/03/06/Assembly-Load-Contexts-Subtleties.aspx" rel="nofollow noreferrer">http://blogs.microsoft.co.il/blogs/sasha/archive/2007/03/06/Assembly-Load-Contexts-Subtleties.aspx</a></p> <p>To answer your question about why the LoadFrom() method is needed. Well, it seems to come down to wanting to load from a specific location and dependencies. Load() resolves dependencies but does not allow you to choose the location of the assembly (i.e., there is a set "probing" structure on where an assembly is tried to be found). LoadFile() guarantees that you will load the assembly that you specify as the string parameter, but does not resolve dependencies. LoadFrom() doesn't guarantee that the assembly you provide in the path will be loaded (i.e., if an assembly with a similar identity is already loaded), but it does resolve dependencies for you.</p> <p>From MSDN</p> <blockquote> <p>Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the LoadFrom context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.</p> </blockquote> <p>From what I have gathered, a shaky consensus seems to form that one should stay away from LoadFile(), use Load() if you can, use LoadFrom() if you need to. But I have seen people say stay away from LoadFrom() too.</p> <p>As a data point, in the Ecma CLI standard ( <a href="http://www.ecma-international.org/publications/standards/Ecma-335.htm" rel="nofollow noreferrer">http://www.ecma-international.org/publications/standards/Ecma-335.htm</a> ), we only standardized the Assembly.Load(string) method, where the string is an assembly name.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload