我收到了错误.有没有其他人得到这个错误?
'/'应用程序中的服务器错误.
无法加载文件或程序集'System.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)
描述:在执行当前Web请求期间发生了未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.异常详细信息:System.IO.FileLoadException:无法加载文件或程序集"System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35"或它的一个依赖.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
来源错误:
第48行:第49行:第50行:}第51行:第52行:protected void Application_BeginRequest(object sender,EventArgs e)
源文件:d:\ SM\7.4Test\WebAPIServerV2\ThirdPartyWebAPI\Global.asax.cs行:50
程序集加载跟踪:下列信息有助于确定程序集"System.Web.Http,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35"无法加载.
===预绑定状态信息===日志:DisplayName = System.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35(完全指定)LOG:Appbase = file:/// D: /SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/日志:初始PrivatePath = D:\ SM\7.4Test\WebAPIServerV2\ThirdPartyWebAPI\bin调用程序集:ThirdPartyWebAPI,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null.===日志:此绑定在默认加载上下文中启动.日志:使用应用程序配置文件:D:\ SM\7.4Test\WebAPIServerV2\ThirdPartyWebAPI\web.config日志:使用主机配置文件:C:\ Users\michalc\Documents\IISExpress\config\aspnet.config日志:使用机器配置来自C:\ Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config的文件.日志:后策略引用:System.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/9184b2ea/c6d4b139/System.Web.Http.DLL.日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/9184b2ea/c6d4b139/System.Web.Http/System.Web.Http .DLL.日志:尝试下载新的URL文件:/// D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL.警告:比较程序集名称导致不匹配:主要版本错误:无法完成程序集的设置(hr = 0x80131040).探测终止.试图下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/9184b2ea/c6d4b139/System.Web.Http/System.Web.Http.DLL .日志:尝试下载新的URL文件:/// D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL.警告:比较程序集名称导致不匹配:主要版本错误:无法完成程序集的设置(hr = 0x80131040).探测终止.试图下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/9184b2ea/c6d4b139/System.Web.Http/System.Web.Http.DLL .日志:尝试下载新的URL文件:/// D:/SM/7.4Test/WebAPIServerV2/ThirdPartyWebAPI/bin/System.Web.Http.DLL.警告:比较程序集名称导致不匹配:主要版本错误:无法完成程序集的设置(hr …
1.启动应用程序时出错
Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.Web.Http.GlobalConfiguration..cctor() +0
[TypeInitializationException: The type initializer for 'System.Web.Http.GlobalConfiguration' threw an exception.]
System.Web.Http.GlobalConfiguration.get_Configuration() +14
SerilogWeb.Classic.WebApi.PreApplicationStartModule.Register() +10
[InvalidOperationException: The pre-application start initialization method Register on type SerilogWeb.Classic.WebApi.PreApplicationStartModule threw an exception with the following error …Run Code Online (Sandbox Code Playgroud) 我希望使用 Swashbuckle 将 Swagger 添加到我的 asp.net REST 服务,如此处所述。
我完成了所有步骤,由于我使用的是 Owin,所以我安装了Swashbuckle和Swashbuckle.Corenugets。
但是,当我运行并导航到时,http://localhost/myapp/swagger出现以下错误。
Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Run Code Online (Sandbox Code Playgroud)
我有5.2.4.01这个 DLL 的版本,所以我添加了以下重定向
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="5.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.2.4.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
我还添加了System.Net.Http.Formatting重定向,因为我在另一篇文章中看到了这一点(但这没有什么区别)
我仍然收到如下错误...
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information === …Run Code Online (Sandbox Code Playgroud) 我们正在努力更新我们计划的框架.我们目前在版本4.5.2中使用它,我们希望将其更新到版本4.7.1
我们已经更改了解决方案的所有csproj,当我们在debug中编译时,应用程序编译并正常工作.但是当我们在发布时执行它时,它会因以下错误而失败:
An attempt was made to load an assembly with an incorrect format: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.IO.Compression.ZipFile.dll
Run Code Online (Sandbox Code Playgroud)
我们真的不知道什么是错的,有谁知道它可能是什么?
非常感谢你.
我知道这个问题在网络和 stackoverflow 上被广泛报道,但我可以通过一些额外的帮助来解决这个问题。我收到与加载 Newtonsoft 相关的运行时错误,请参见下文;
[11/07/2020 18:37:17] A ScriptHost error has occurred
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. mscorlib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
[11/07/2020 18:37:17] Exception while executing function: Alerts
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: …Run Code Online (Sandbox Code Playgroud)