[英].Net Core Nuget Package Version mismatch: Two packages have references to different versions of the same dll
[英].NET: Load two version of the same DLL
我需要加載同一DLL的兩個版本,以便比較它們的輸出。 我假設我可以使用AppDomains,但我需要一些指導。
好吧,它實際上比我想象的容易得多。
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")
從現在開始,我使用后期綁定和/或反射來運行我的測試。
在MSDN上查看Activator.CreateInstance()。 代碼示例。
這是一個指南:
extern alias oldVer;
extern alias newVer;
當你編譯:
csc /r:oldVer=Somepath\ClassLibrary.dll /r:newVer=AnotherPath\ClassLibrary.dll program.cs
或者在Visual Studio中更改項目引用的屬性選項卡中的“別名”字段
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.