Assembly的LoadFile()和LoadFrom()的区别

Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. Do not use LoadFile to load assemblies that you want to execute.
LoadFile does not load files into the LoadFrom context, and does not resolve dependencies usingthe load path, as the LoadFrom method does. LoadFile is useful in this limited scenario becauseLoadFrom cannot be used to load assemblies that have the same identities but different paths; itwill load only the first such assembly.


即不同物理位置的相同程序集通过LoadFile加载后,实例化其中的对象后不能进行类型比较,因为没有相同的环境。所以在类似插件系统的程序集动态加载的实现中应该使用LoadFrom方法(btw:调用后不会自动加载依赖的程序集)。

你可能感兴趣的:(assembly)