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

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

问题描述

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



我已经调查了使用extern alias功能的c#进程来拉入不同的程序集。



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



程序集引用的别名属性有什么用在Visual Studio 8中



似乎此功能并不完全可用于vb.net。



我尝试过的东西



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



所以我需要别名不同的版本。在vb.net中,您可以在导入语句中执行别名,如:

 导入version5 = Somedll.Something 

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

 < Reference Include =somedll.5.Navigation> ; 
< HintPath> .. \..\Utility\ThirdPartyDLLS\somedll.5.dll< / HintPath>
<别名> 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>
<别名> SomeDLL6< / Aliases>
< Private> False< / Private>
< / Reference>

我会期望这样工作:

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

但是,SomeDLL5 / 6不会显示在智能感知中。那么如何在同一个项目中引用这两个DLL呢?

解决方案

我是VB规范的主角。恐怕没有VB的做法(没有反思,就像DaMartyr所说)。我知道这是一个拖累。我将把它列入下一届VB语言设计大会的议程。


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.

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

What use is the Aliases property of assembly references in Visual Studio 8

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

Things I've Tried

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.

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

Imports version5 = Somedll.Something

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

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

解决方案

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天全站免登陆