.NET - 具有相同的命名空间多库 - 引用 [英] .NET - Multiple libraries with the same namespace - referencing
问题描述
今天,我面临着一个奇怪的挑战...
Today I am faced with a curious challenge...
这挑战涉及到,我需要从我的应用程序两个参考.NET库。这两者在我无法控制并在其中相同的命名空间。
This challenge involves two .NET libraries that I need to reference from my application. Both of which I have no control over and have the same namespace within them.
所以...
我有 foo.dll
包含位于 Blue.Red一个
命名空间。小部件
类.Orange
I have foo.dll
that contains a Widget
class that is located on the Blue.Red.Orange
namespace.
我 bar.dll
还包含一个小部件
类,它也位于 Blue.Red.Orange
命名空间。
I have bar.dll
that also contains a Widget
class that is also located on the Blue.Red.Orange
namespace.
最后,我有我的应用程序需要同时引用 foo.dll
和 bar.dll
。这是需要我的应用程序中,我需要使用小部件
类从富
,并在小部件
类栏
Finally I have my application that needs to reference both foo.dll
and bar.dll
. This is needed as within my application I need to use the Widget
class from foo
and also the Widget
class from bar
所以,问题是,我该怎么管理这些引用,以便我可以肯定我使用的是正确的小部件
类?
So, the question is how can I manage these references so that I can be certain I am using the correct Widget
class?
正如前面提到的,我管不着在富
或栏
库,它们是它们是什么,不能改变。不过我也有超过我的应用程序的完全控制。
As mentioned, I have no control over the foo
or bar
libraries, they are what they are and cannot be changed. I do however have full control over my application.
推荐答案
您需要使用的 外部别名的 - 在C#2中引入
You need to use an extern alias - introduced in C# 2.
安森霍顿在他的博客一个演练,您可能发现有用的。
Anson Horton has a walkthrough on his blog which you may find useful.
这篇关于.NET - 具有相同的命名空间多库 - 引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!