.NET:加载同一个 DLL 的两个版本 [英] .NET: Load two version of the same DLL

查看:44
本文介绍了.NET:加载同一个 DLL 的两个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要加载同一个 DLL 的两个版本,以便比较它们的输出.我假设我可以为此使用 AppDomains,但我需要一些指导.

I need to load two versions of the same DLL in order to compare their outputs. I assume that I can use AppDomains for this, but I need some guidence.

推荐答案

好吧,实际上比我想象的要容易得多.

Ok, it was actually a lot easier than I imagined.

    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.

这篇关于.NET:加载同一个 DLL 的两个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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