问题描述
我一直在试图破解这一个过去的几个星期,还没有找到一个很好的解决方案还没有; 。希望我能在这里得到答案
我有两个组件(ZA&安培; ZB),两者都指向一个共同的项目/ DLL(ZC),但可能的放在一个不同的版本(即相同的DLL名称,相同的命名空间,有些类可能会有所不同)。每个组装工作本身,但是,如果一个人被另一个在运行时(例如,A负载B)加载,那么我无法得到它的工作。 。需要一些帮助。
下面的设置:
- ZA取决于ZC(常见的)1.1版
- ZB取决于ZC 1.0版本
ZA需要需要加载到加载ZB的东西(这取决于ZC),在运行时。
ZA是主应用程序。
在其斌
目录中,有一个插件目录插件/插件-ZB
下我想。将所有ZB和它的依赖(ZC)的
下面是我到目前为止已经试过:
的Assembly.Load()
使用的DLL版本相同 - 正常工作
大会。负荷()
使用不同版本的DLL - ZB负荷,但该方法运行时,我得到找不到方法的异常
AppDomain.Load()
有没有发现错误的文件;我甚至用委托来解决组件
有关ZC一些细节:
- 有些方法是公共静态(有些则不是)。例如。 Log.Log(你好);
- 有些人可能返回值(原语或对象)。
- 有些方法是非静态的(和返回值)
帮助? - TIA
m_Assembly1 = Reflection.Assembly.LoadFile(IO.Path.Combine( System.Environment.CurrentDirectory,老Version\Some.dll))
m_Assembly2 = Reflection.Assembly.LoadFile(IO.Path.Combine(System.Environment.CurrentDirectory,新Version\Some.dll ))
Console.WriteLine(旧版本:&放大器; m_Assembly1.GetName.Version.ToString)
Console.WriteLine(新版本:&放大器; m_Assembly2.GetName.Version。的ToString)
m_OldObject = m_Assembly1.CreateInstance(FullClassName)
m_NewObject = m_Assembly2.CreateInstance(FullClassName)
从现在开始我用后期绑定和/或反射来运行我的测试。
的
I've been trying to crack this one over the last couple of weeks and have not found a good solution yet; hopefully I can get an answer here.
I have two assemblies (ZA & ZB), both of which point to a common project/dll (ZC) but which could be on a different version (i.e. same dll name, same namespaces, some classes may be different). Each assembly works by itself, however, if one is loaded by the other at runtime (e.g. A loads B), then I cannot get it to work. Need some help.
Here's the setup:
- ZA depends on ZC (common) version 1.1
- ZB depends on ZC version 1.0
ZA needs to load needs to load something in ZB (which depends on ZC), at runtime.
ZA is the master app.Under its bin
directory, there's a plugins directory plugins/plugin-ZB
under which I would like to place all of ZB and its dependencies (ZC).
Here's what I've tried so far:
Assembly.Load()
using same version of dll - worked fine.
Assembly.Load()
using different versions of dll - ZB loads, but when the method runs, I get a method not found exception.
AppDomain.Load()
got a file not found error; I even used the delegate to resolve assemblies.
Some details regarding ZC:- some methods are public static (some are not). E.g. Log.Log("hello");
- some may return values (primitives or objects).- some methods are non static (and return values).
Help? - TIA
m_Assembly1 = Reflection.Assembly.LoadFile(IO.Path.Combine(System.Environment.CurrentDirectory, "Old Version\Some.dll"))
m_Assembly2 = Reflection.Assembly.LoadFile(IO.Path.Combine(System.Environment.CurrentDirectory, "New Version\Some.dll"))
Console.WriteLine("Old Version: " & m_Assembly1.GetName.Version.ToString)
Console.WriteLine("New Version: " & m_Assembly2.GetName.Version.ToString)
m_OldObject = m_Assembly1.CreateInstance("FullClassName")
m_NewObject = m_Assembly2.CreateInstance("FullClassName")
From here on out I used late binding and/or reflection to run my tests.
http://stackoverflow.com/questions/2016990/net-load-two-version-of-the-same-dll/2023445#2023445
这篇关于在运行时加载2个版本装配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!