且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

结合在.net中的重定向问题

更新时间:2023-10-25 21:39:16

这完全为我工作。注意:您需要在配置标签没有命名空间。你必须对你的 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.

< assemblyBinding>元素<&运行GT;

<!-- 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/