另一个程序集引用了旧的dll。

3
我有两个程序集,称为A和B。我已经为它们分配了强名称,现在出现问题,即程序集B正在寻找程序集A的旧版本。 **编辑2:如果我删除AssemblyB,问题仍然存在,所以可能只是VS2008在寻找旧版本?此外,通过fusionlog,我看到以下警告:wrn应用程序配置文件绑定重定向不允许。这与此有关吗?** 我得到了多个相同类型的错误,这里是一个片段:
You must add a reference to assembly 'AssemblyA, Version=1.2.4737.25316, Culture=neutral, PublicKeyToken=null'.

项目中的强名称AssemblyA显示以下属性: enter image description here 我在app.config中放置了以下代码:
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="AssemblyA" culture="neutral"
    publicKeyToken="a22e30ac6a0edfc0"/>
            <bindingRedirect oldVersion="1.2.4737.25316" newVersion="1.3.0.19440"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

但是这并不起作用。我可以访问这两个程序集的源代码。
编辑:如果我删除强名称并向项目添加旧版本(弱命名)的dll,它将会出现一个错误,询问强命名版本的情况。
You must add a reference to assembly 'AssemblyA, Version=1.3.0.19440, Culture=neutral, PublicKeyToken=a22e30ac6a0edfc0'.

这里发生了什么?
1个回答

3
一些DLL仍然引用了其他DLL的旧版本(弱命名)。幸运的是,这些程序集都附带了源代码,因此我不得不重新编译所有内容,包括密钥。
之后,又出现了另一个错误,类似于“找到的程序集清单定义与程序集引用不匹配”。
为了解决这个问题,我在app.config中添加了以下内容。
<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <publisherPolicy apply="no" />
            <assemblyIdentity name="Assemblyname" culture="neutral" publicKeyToken="3a5628535d42dbed"/>
            <bindingRedirect oldVersion="1.3.0.15233" newVersion="1.3.0.40647" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

如果我在一个没有app.config的项目中怎么办? - Shady M. Najib
@ShadyM.Najib 取决于你正在处理的项目类型。你可以尝试通过这种方法添加它:http://msdn.microsoft.com/en-us/library/ms184658(v=vs.90).aspx。如果你正在使用SSIS脚本组件,你可以尝试更改此文件:C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DtsDebugHost.exe.config,在<configuration>标记之间放置代码片段。 - tutu
实际上,我指的是不支持配置文件的项目类型.. 例如 Windows 8 项目 :D - Shady M. Najib
@ShadyM.Najib 抱歉,我无法帮助你。你可以尝试使用谷歌搜索,我找到了这个链接:http://www.geekchamp.com/forums/windows-8-development/app-config---web-config-missing-in-windows-8-apps--what-is-the-equivalent. - tutu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接