.NET - Multiple libraries with the same namespace - referencing(.NET - 具有相同命名空间的多个库 - 引用)
问题描述
今天我面临着一个奇怪的挑战......
这个挑战涉及我需要从我的应用程序中引用的两个 .NET 库.两者我都无法控制,并且在它们中具有相同的命名空间.
所以...
我的 foo.dll 包含一个 Widget 类,该类位于 Blue.Red.Orange 命名空间中.
我的 bar.dll 还包含一个 Widget 类,该类也位于 Blue.Red.Orange 命名空间中.p>
最后,我的应用程序需要同时引用 foo.dll 和 bar.dll.这是需要的,因为在我的应用程序中,我需要使用 foo 中的 Widget 类以及 bar 中的 Widget 类>
那么,问题是如何管理这些引用,以便确定我使用的是正确的 Widget 类?
如前所述,我无法控制 foo 或 bar 库,它们就是它们的本来面目,无法更改.但是,我可以完全控制我的应用程序.
您需要使用 extern alias - 在 C# 2 中引入.
Anson Horton 在他的博客上有一个演练,您可以觉得有用.
Today I am faced with a curious challenge...
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.
So...
I have foo.dll that contains a Widget class that is located on the Blue.Red.Orange namespace.
I have bar.dll that also contains a Widget class that is also located on the Blue.Red.Orange namespace.
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.
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 - 具有相同命名空间的多个库 - 引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:.NET - 具有相同命名空间的多个库 - 引用
基础教程推荐
- 从 C# 控制相机设备 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 将数据集转换为列表 2022-01-01
