ASP.Net Core 从 VS2015 迁移到 VS2017 时无法加载文件或程序集“System.Diagnostics.DiagnosticSource" [英] Could not load file or assembly 'System.Diagnostics.DiagnosticSource on ASP.Net Core migration from VS2015 to VS2017

查看:17
本文介绍了ASP.Net Core 从 VS2015 迁移到 VS2017 时无法加载文件或程序集“System.Diagnostics.DiagnosticSource"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ASP.Net Core(4.6.1 框架)中有一个网络,它使用我用 Visual Studio 2015 创建并在昨天发布的新 Visual Studio 2017 中打开的 Facebook 和 MS 外部登录.VS2017对csproj、project.json等文件做了一些改动.

网站编译和执行都很好,除了一个部分.如果我使用 Facebook 或 Microsoft 外部登录,该网站会显示以下陷阱:

FileLoadException: 无法加载文件或程序集 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' 或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.(来自 HRESULT 的异常:0x80131040)System.Net.Http.WinHttpHandler.SendAsync(HttpRequestMessage 请求,CancellationToken cancelToken)AggregateException:未处理的远程故障.Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler+<HandleRemoteCallbackAsync>d__6.MoveNext()

浏览器中的url显示它正在尝试从外部登录返回到本地(

解决方案

为我解决的问题是向新迁移的项目添加对 System.Net.Http(版本 4.3.1)的 NuGet 引用.https://www.nuget.org/packages/System.Net.Http/

I have a web in ASP.Net Core (4.6.1 framework) that uses Facebook and MS external login that I created with Visual Studio 2015 and opened in the new Visual Studio 2017 that came out yesterday. VS2017 made a few changes related to the csproj, project.json, etc files.

The site compiled and executed fine except for one part. If I did a Facebook or Microsoft external login, the site displayed this trap:

FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

System.Net.Http.WinHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
AggregateException: Unhandled remote failure.

Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler+<HandleRemoteCallbackAsync>d__6.MoveNext()

The url in the browser showed that it was attempting to return from the external login to the local (https://localhost:44321/signin-facebook?code=... or /signin-microsoft).

The version number of the System.Diagnostics.DiagnosticSource.dll (and System.Net.Http.dll) is 4.6.24705.1.

I started a new VS2017 project from scratch with Facebook and MS login added and it worked fine - getting me logged on without the trap. The dll's were the same versions.

Comparing the two csproj files showed differences but nothing obvious (nothing related to System dlls):

解决方案

What solved it for me was to add a NuGet reference to System.Net.Http (version 4.3.1) to the newly migrated project. https://www.nuget.org/packages/System.Net.Http/

这篇关于ASP.Net Core 从 VS2015 迁移到 VS2017 时无法加载文件或程序集“System.Diagnostics.DiagnosticSource"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆