我正在尝试在运行时从应用程序加载多个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.
更多推荐
版本冲突
发布评论