gpt4 book ai didi

c# - 无法加载文件或程序集 'System.Net.Http.Formatting-Cosmo'

转载 作者:太空狗 更新时间:2023-10-30 00:37:33 25 4
gpt4 key购买 nike

这个错误是突然发生的。使用 Visual Studio 2017,System.Net.Http.Formatting 问题已经好几年没有被提起了。

我只在网页上看到这条消息:

Could not load file or assembly 'System.Net.Http.Formatting-Cosmo' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

连同回溯:

     === Pre-bind state information ===
LOG: DisplayName = System.Net.Http.Formatting-Cosmo
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Net.Http.Formatting-Cosmo | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/George/OneDrive/SignupList/SignupList/
LOG: Initial PrivatePath = C:\Users\George\OneDrive\SignupList\SignupList\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\George\OneDrive\SignupList\SignupList\web.config
LOG: Using host configuration file: C:\Users\George\OneDrive\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/George/AppData/Local/Temp/Temporary ASP.NET Files/vs/6cc2628d/51b3c1a6/System.Net.Http.Formatting-Cosmo.DLL.
LOG: Attempting download of new URL file:///C:/Users/George/AppData/Local/Temp/Temporary ASP.NET Files/vs/6cc2628d/51b3c1a6/System.Net.Http.Formatting-Cosmo/System.Net.Http.Formatting-Cosmo.DLL.
LOG: Attempting download of new URL file:///C:/Users/George/OneDrive/SignupList/SignupList/bin/System.Net.Http.Formatting-Cosmo.DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

似乎停止尝试在配置中找到具有正确版本的 DLL 的 System.Net.Http.Formatting。

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

我使用的是 ASP.NET 而不是 MVC,我不知道为什么需要 System.Net.Http.Formatting。 Cosmo 是我电脑的名字。我希望 -Cosmo 不是问题,我不明白为什么会这样。

我做了 Stack Overflow 上一篇 4 年前的帖子中提到的所有内容 - Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified没有解决它。我找到了其他帖子并使用了 Microsoft.AspNet.WebApi.Core V 5.2.4,它放置了 System.Net.Http.Formatting V 5.2.3.0。

本地副本属性在 System.Net.Http.Formatting 引用中设置为 True。她重新收到了所有包裹。该项目已重新初始化。我已经尝试了所有我能找到的建议。

在没有 Microsoft.AspNet.WebApi.Core 的情况下,如果我编译我会收到编译错误,提示缺少 System.Net.Http.Formatting。重新添加 Core,编译时错误消失。由于依赖关系,我还必须使用 Microsoft.AspNet.WebApi.Core 删除并重新添加 Microsoft.AspNet.WebApi.WebHost。运行该网页时,该网页会在我项目中每个 ASPX 文件的第一行以及第一行给出错误。

我也有与此相关的 Newtonsoft.Json。

      <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2014.3.1209.45" newVersion="2014.3.1209.45" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.25.0.0" newVersion="1.25.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.25.0.0" newVersion="1.25.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

程序集正在寻找 System.Net.Http.Formatting-Cosmo 并尝试下载它。 System.Net.Http.Formatting 位于 bin 中,我什至添加了 System.Net.Http.Formatting-Cosmo 以防万一。版本匹配。为什么找不到 bin DLL? -Cosmo 有问题吗?

令人费解。

乔治

最佳答案

它现在已修复,但我不确定它是如何修复的,因为我尝试了很多不同的东西,包括更新 Visual Studio 和摆脱旧的 Visual Studios,这些旧的 Visual Studios 没有解决问题但确实做了一点改变。

我注意到 System.Net.Http.Formatting.dll 的版本为 5.2.60201.0。环顾四周,我发现 Microsoft.AspNet.WebApi.Client 也可能参与其中。

使用 NuGet 包管理器,我删除了 Microsoft.AspNet.WebApi.WebHost、Microsoft.AspNet.WebApi.Core 和 Microsoft.AspNet.WebApi.Client。然后我重新添加了所有 3 个中的最新版本 5.2.4。客户端包为 5.2.2。

现在Web.config中System.Net.Http.Formatting的dependentAssembly有newVersion="5.2.4.0"。 DLL 上的版本是 5.2.60201.0,所以我期待它能看到问题,但它起作用了。寻找 System.Net.Http.Formatting 版本 5.2.4.0 似乎可以找到 5.2.60201.0,而 5.2.3.0 则不能。

正如我认为更好地理解它一样,它运行良好。肯定是一次学习经历。

最后我相信,

  • Microsoft.AspNet.WebApi.WebHost
  • Microsoft.AspNet.WebApi.Client
  • Microsoft.AspNet.WebApi.Core

都应该是在 NuGet 管理器的依赖项中确认的相同版本。

关于c# - 无法加载文件或程序集 'System.Net.Http.Formatting-Cosmo',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48877067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com