在 vb.net 3.5 项目中使用相同命名空间的引用 2 dll?

Reference 2 dlls using the same namespace in vb.net 3.5 project?(在 vb.net 3.5 项目中使用相同命名空间的引用 2 dll?)

本文介绍了在 vb.net 3.5 项目中使用相同命名空间的引用 2 dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 vb.net 3.5 类库项目,它需要引用两个具有相同命名空间的程序集.我们有两个第三方 dll,其中一个是 5.1 版,另一个是 6.1 版.它们具有相同的 dll 文件名,并且使用相同的命名空间和函数/类名.项目需要根据具体情况使用其中一种.

I have a vb.net 3.5 class library project that needs to reference two assemblies that have the same namespace. We have two third party dll's in which one is version 5.1 and the other is version 6.1. They have the same dll filename and they utilize the same namespace and functions/class names. The project needs to use one or the other depending on a specific situation.

我研究了一个使用外部别名"功能来拉入不同程序集的 c# 进程.

I've investigated up on a c# process that uses the "extern alias" feature to pull in the different assemblies.

http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx

有什么用Visual Studio 8 中程序集引用的 Aliases 属性

似乎此功能不适用于 vb.net.

It seems that this feature isn't fully available for vb.net.

我尝试过的事情

我已重命名第二个 dll 并将两个引用都添加到我的项目中.在这一点上,我得到了很多:'blah' 在命名空间中不明确.

I've renamed the 2nd dll and added both references to my project. At this point I get tons of: 'blah' is ambiguous in the namespace.

所以我需要给不同的版本起别名.在 vb.net 中,您可以在导入语句上使用别名,例如:

So I need to alias the different versions. In vb.net you can do aliases on an imports statement like:

Imports version5 = Somedll.Something

问题是我无法为不同版本的 dll 设置程序集引用别名.显然在 vb.net 中,您无法在参考属性窗口中进行设置.所以我尝试将它们设置在我的项目文件中,如下所示:

The problem is I can't setup an assembly reference alias for the different versions of the dll. Apparently in vb.net you can't set these up in the reference properties window. So I tried setting them in in my project file like this:

<Reference Include="somedll.5.Navigation">
  <HintPath>....UtilityThirdPartyDLLSsomedll.5.dll</HintPath>
      <Aliases>SomeDLL5</Aliases>
      <Private>False</Private>
</Reference>
<Reference Include="somedll.6.Navigation, Version=6.1.0.0, Culture=neutral, PublicKeyToken=6d02be8724ca751c, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>....UtilityThirdPartyDLLSsomedll.6.dll</HintPath>
      <Aliases>SomeDLL6</Aliases>
      <Private>False</Private>
</Reference>

然后我希望这会起作用:

I would then expect this to work:

Imports version5 = SomeDLL5.Something
Imports version6 = SomeDLL6.Something

但是SomeDLL5/6"没有出现在智能感知中.那么如何在同一个项目中引用两个 dll 呢?

But the "SomeDLL5/6" doesn't show up in intellisense. So how can I reference both dll's in the same project?

推荐答案

我是 VB 规范负责人.恐怕没有 VB 方法可以做到这一点(正如 DaMartyr 所说,缺少反射).我知道这是一个拖累.我会将它列入我们下一次 VB 语言设计会议的议程.

I'm the VB spec lead. I'm afraid that there's no VB way of doing this (short of reflection, as DaMartyr said). I know this is a drag. I'll put it on the agenda for our next VB Language Design Meeting.

这篇关于在 vb.net 3.5 项目中使用相同命名空间的引用 2 dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 vb.net 3.5 项目中使用相同命名空间的引用 2 dll?

基础教程推荐