【问题标题】:Another assembly referencing the old dll另一个引用旧 dll 的程序集
【发布时间】:2013-03-28 10:35:46
【问题描述】:

我有 2 个程序集,我们分别称它们为 A 和 B。我已经为它们分配了强名称,现在问题出现了,程序集 B 正在寻找旧版本的程序集 A。 ** EDIT2:如果我删除 AssemblyB 问题仍然存在,那么它可能只是 VS2008 正在寻找旧版本?同样通过 fusionlog 我看到以下警告:wrn application configuration file binding redirects disallowed。这有什么关系吗? **

我收到多个相同类型的错误,这是一个 sn-p:

You must add a reference to assembly 'AssemblyA, Version=1.2.4737.25316, Culture=neutral, PublicKeyToken=null'.

项目中的强命名 AssemblyA 显示以下属性:

我在 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'.

这里发生了什么?

【问题讨论】:

    标签: c# assemblies .net-assembly


    【解决方案1】:

    某些 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 怎么办
    • @ShadyM.Najib 取决于您正在进行的项目类型。您可以尝试通过以下方法添加它:msdn.microsoft.com/en-us/library/ms184658(v=vs.90).aspx。如果您正在使用 SSIS 脚本组件,您可以尝试更改此文件:C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DtsDebugHost.exe.config,将这段代码放在 标记之间.
    • 其实我的意思是一个不支持配置文件的项目类型。Windows 8 项目例如:D
    • @ShadyM.Najib 抱歉不能帮你。你可以试试谷歌,发现这个:geekchamp.com/forums/windows-8-development/….
    猜你喜欢
    • 1970-01-01
    • 2012-02-16
    • 2012-09-29
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    相关资源
    最近更新 更多