参考2的DLL使用相同的命名空间在vb.net 3.5的项目? [英] Reference 2 dlls using the same namespace in vb.net 3.5 project?

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

问题描述

我有需要引用两个程序集具有相同的名称空间中的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 /存档/ 2006/09/27 / 774692.aspx

<一个href="http://stackoverflow.com/questions/286632/what-use-is-the-aliases-property-of-assembly-references-in-visual-studio-8">What使用是在Visual Studio程序集引用别名属性8

看来,这个功能并不完全适用于vb.net。

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

事情

我已经改名为第2个的DLL并添加两个引用到我的项目。在这一点上,我得到吨: '嗒嗒'不明确的命名空间

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>..\..\Utility\ThirdPartyDLLS\somedll.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>..\..\Utility\ThirdPartyDLLS\somedll.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.

这篇关于参考2的DLL使用相同的命名空间在vb.net 3.5的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆