.net 中的绑定重定向问题 [英] Binding redirect problem in .net

查看:28
本文介绍了.net 中的绑定重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为MyAssembly"的类库,它在内部引用了 3.1.1.0 版本的 a.dll、b.dll;我已经构建了输出 MyAssembly.dll 的项目.在不同的系统(框)上,我创建了一个 Web 应用程序项目并引用了 MyAssembly.dll.新系统有新版本的a.dll和b.dll 4.0.0;我在 web.config 中使用了绑定重定向,如下所示.但是仍然无法编译Web应用程序.它说缺少程序集引用 a.dll,版本 3.1.1.0.

I have a class library called "MyAssembly" that is internally referencing a.dll, b.dll of version 3.1.1.0; I have build the project which outputed MyAssembly.dll. On a different system (box) I have created a web application project and referenced the MyAssembly.dll. the new system has new versions of a.dll and b.dll 4.0.0; I used binding redirect in web.config like below. But still unable to compile the web application. it says missing assembly reference a.dll, version 3.1.1.0.

任何机构都可以帮助解决这个问题吗?

Could any body help in solving this issue?

谢谢,苏雷什

推荐答案

这对我来说完全有用.注意:configuration 标签上需要NO 命名空间.并且您必须在 assemblyBinding 标记上有一个命名空间.

This totally worked for me. NOTE: You need NO namespace on the configuration tag. And you MUST have a namespace on your assemblyBinding tag.

<runtime>

<!-- important: no namespace -->
<configuration> 
  <runtime>
    <!-- important, must have this namespace -->
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly>
        <assemblyIdentity name="Strongly.Named.Assembly" publicKeyToken="xxx" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

这两个都做,否则它不会读取它.如果它给出一个错误,在这个例子中它不能加载除了 2.0.0.0 之外的任何东西,那么它没有正确地获取配置元素.

Do both of those or else it will not read it. If it is giving an error that it cannot load anything but 2.0.0.0 in this example, then it is not picking up the config elements properly.

这也仅适用于强命名程序集.要找出某些东西是否具有强命名,请从 VC 命令窗口运行以下命令

This also only works on strongly named assemblies. To find out if something is strongly named run the following command from the VC command window

打开(开始菜单 > 所有程序 > Visual Studio > Visual Studio 工具 > Visual Studio 命令提示符)

open (start menu > all programs > visual studio > visual studio tools > visual studio command prompt)

然后运行:

sn -vf "path-to-assembly.dll"

如果它返回它是有效的,那么它就是强命名的.

If it returns that it is valid, then it's strongly named.

来源:http://blog.codingoutloud.com/2010/03/13/three-ways-to-tell-whether-an-assembly-dl-is-strong-named/

这篇关于.net 中的绑定重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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