版本冲突 - assembly.loadfrom [英] Version conflict - assembly.loadfrom

查看:65
本文介绍了版本冲突 - assembly.loadfrom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在运行时从应用程序加载多个dll。

例如如下所示。



I am trying to load multiple dlls from an application at runtime.
For example like below.

Assembly assembly = Assembly.LoadFrom("MyNice.dll");
Type type = assembly.GetType("MyType");
object instanceOfMyType = Activator.CreateInstance(type);

Assembly assembly = Assembly.LoadFrom("MyAnotherNice.dll");
Type type = assembly.GetType("MyType");
object instanceOfMyType = Activator.CreateInstance(type);





两个



Both

MyNice.dll and MyAnotherNice.dll

指的是具有不同版本的同一个库。说Reflib.dll和Reflib.dll。



问题:这是否可行,如果是,将如何解析

are referring to a same library with different versions. Say Reflib.dll and Reflib.dll.

Question : Is this possible and if yes how will the versions of

Reflib.dll  

库引用的版本运行时因为两个版本在功能上都有很大差异。



我尝试过:



我还没有真正尝试过这个,但我要求实现这一点,我确信我有这样的方案来处理。我正在寻找专业人士遵循或采用的最佳实践。

library reference will get resolved runtime as both the version has significant differences in functionality.

What I have tried:

I have not really tried this,but I have requirement to implement this and I am sure I have such scenario to handle. I am looking for the best practices professionals follow or adopt.

推荐答案

在这种情况下,我倾向于使用单独的AppDomains来保持良好和干净。我在前一段时间编写插件处理程序并使用AppDomains解决它以加载程序集及其依赖项时遇到了这种情况。
In this scenario, I would tend to use separate AppDomains to keep things nice and clean. I have encountered exactly this scenario when I wrote a plugin handler a while back and solved it using AppDomains to load the assemblies and their dependencies.


这篇关于版本冲突 - assembly.loadfrom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆