2009-08-14 33 views
2

在Visual Studio中,可以要求程序集引用与程序集的特定版本相匹配。有可能(可能通过直接编辑文本编辑器中的csproj或vbproj文件)引用一系列版本。在Visual Studio中添加对具有特定版本的程序集的引用

我的具体示例是我想在我的测试项目中引用版本号为2.5的nUnit。人们运行不同版本的nUnit,并且nUnit版本2.5.x中的任何内容都足以运行我们的单元测试。

回答

3

在你的编译设置中,我不这么认为。

但是,您可以将应用程序配置为重定向程序集加载请求。看看Assembly Binding Redirection。您可以将特定版本(或版本范围)的加载请求配置为在运行时重定向到不同的东西。

这个例子稍微从MSDN修改:

<configuration> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="myAssembly" 
           publicKeyToken="32ab4ba45e0a69a1" 
           culture="neutral" /> 
      <bindingRedirect oldVersion="0.0.0.0-99.99.99.99" 
          newVersion="2.0.0.0"/> 
     </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

设置名称,公钥和NEWVERSION正确的属性,你应该是好去。

相关问题