您的位置:首页 > 其它

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

2006-07-30 22:04 507 查看
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 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.

即不同物理位置的相同程序集通过LoadFile加载后,实例化其中的对象后不能进行类型比较,因为没有相同的环境。所以在类似插件系统的程序集动态加载的实现中应该使用LoadFrom方法(btw:调用后不会自动加载依赖的程序集)。
http://www.cnblogs.com/kozen
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  assembly dependencies path
相关文章推荐