向 C# 项目添加依赖项 - 不同版本的相同程序集

发布于 2024-09-17 07:23:07 字数 506 浏览 5 评论 0原文

我需要能够从驻留在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

君勿笑 2024-09-24 07:23:07

我认为您正在寻找外部别名

I think you are looking for extern alias.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文