向 C# 项目添加依赖项 - 不同版本的相同程序集
我需要能够从驻留在 GAC 中的同一程序集的不同版本调用实用程序:
gacutil /l TestAssembly
TestAssembly.dll, Version=1.0.0.0 ....
TestAssembly.dll, Version=2.0.0.0 ....
并且在代码中的某处我需要动态加载其中一个:
TestObject testObject;
if (loadFromVersion1)
{
testObject = // instantiate test object from the first assembly
}
else
{
testObject = // instantiate test object from the second assembly
}
有没有一种方法可以在不反射的情况下执行此操作(我知道如何通过反射来完成此操作) )并使用强类型对象代替?
I need to be able to call utilities from different versions of the same assembly both residing in GAC:
gacutil /l TestAssembly
TestAssembly.dll, Version=1.0.0.0 ....
TestAssembly.dll, Version=2.0.0.0 ....
And somewhere in code I need to dynamically load either one:
TestObject testObject;
if (loadFromVersion1)
{
testObject = // instantiate test object from the first assembly
}
else
{
testObject = // instantiate test object from the second assembly
}
Is there a way to do this without reflection (i know how to accomplish this with reflection) and use strongly typed objects instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找外部别名。
I think you are looking for extern alias.