【问题标题】:Errors after installation Breeze framework on ASP.NET Web Api Project在 ASP.NET Web Api 项目上安装 Breeze 框架后的错误
【发布时间】:2014-12-12 15:02:35
【问题描述】:

我有 ASP.NET Web Api 2.2 项目。我在这个项目上通过 nuget 安装了微风:

安装 Breeze 框架后出现错误,现在无法构建项目:

  1. 错误程序集 'System.Web.Http.OData, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 使用 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken =31bf3856ad364e35',其版本高于引用的程序集 'System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' c:\Users\Home\Documents\Visual Studio 2013\Projects\MyProject\packages \Microsoft.AspNet.WebApi.OData.5.2.2\lib\net45\System.Web.Http.OData.dll

  2. 错误 - 程序集 'System.Web.Http.OData, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 使用 'System.Net.Http.Formatting, Version=5.2.2.0, Culture=中性,PublicKeyToken=31bf3856ad364e35',其版本高于引用的程序集 'System.Net.Http.Formatting, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' c:\Users\Home\Documents\Visual Studio 2013\ Projects\MyProject\packages\Microsoft.AspNet.WebApi.OData.5.2.2\lib\net45\System.Web.Http.OData.dll

虽然库是新版本。

当我在“解决方案资源管理器”中打开我的项目的“参考”并双击“System.Web.Http”时

它会打开“对象浏览器”选项卡。我有几个版本的“System.Web.Http”。 H

我可以说使用我需要的版本吗? 我该如何解决这个问题?

【问题讨论】:

    标签: c# asp.net asp.net-web-api nuget breeze


    【解决方案1】:

    这个问题的解决方法很简单。您需要从项目中删除对该库的引用。然后检查它是否已在 bin 文件夹中删除。如果没有,请手动删除。然后添加对所需版本库的新引用。

    由于某些原因,当您引用同一库的另一个版本时,VS 不会替换库。

    【讨论】:

      【解决方案2】:

      @KrishnaTejaVeeramachaneni - 你给了他所有的程序集重定向,除了消息中标识的程序集:System.Web.Http.OData

      将其添加到组合中:

        <dependentAssembly>
          <assemblyIdentity name="System.Web.Http.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
        </dependentAssembly>
      

      我的应用中有大量此类重定向。这是 DocCode 的 Web.config 的整个部分:

      <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
              <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="System.Web.Http.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Http.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.2.0" newVersion="5.6.2.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.2.0" newVersion="5.6.2.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.2.0" newVersion="5.6.2.0" />
            </dependentAssembly>
          </assemblyBinding>
      </runtime>
      

      【讨论】:

        【解决方案3】:

        您必须将 web.config 中的以下设置更新为类似的内容。 好像当你安装了 nuget 包时,默认的 web.config 设置没有正确更新。

          <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
          </dependentAssembly>
        

        【讨论】:

        • 同样的问题 - 它没有帮助
        • 尝试删除引用并手动添加回来。它可能会删除那些多个版本。
        • 我试过了,但是当我添加新版本的 dll 时,它会添加旧版本
        • 最后一次尝试...试试我的新答案。它是说一直到 5.2.2.0 的任何版本现在都应该使用新版本的 5.2.2.0。我没有看到您拥有的 System.Net.Http.Formatting 版本。因此,请根据您拥有的内容使用正确的版本号。
        猜你喜欢
        • 2020-01-23
        • 1970-01-01
        • 2023-03-10
        • 2017-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-17
        相关资源
        最近更新 更多