8

我在使用我創建的Facebook和MS外部登錄的ASP.Net Core(4.6.1框架)中有一個Web與Visual Studio 2015並在昨天推出的新的Visual Studio 2017中打開。 VS2017做了一些與csproj,project.json等文件相關的更改。無法加載ASP.Net上的文件或程序集System.Diagnostics.DiagnosticSource從VS2015到VS2017的核心遷移

該網站編譯和執行良好,除了一部分。如果我做了一個Facebook或微軟外部登錄,該網站顯示的這個陷阱:

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() 

在瀏覽器的URL表明,它試圖從外部登錄返回到本地(https://localhost:44321/signin-facebook?code= ...或/登入-微軟)。

System.Diagnostics.DiagnosticSource.dll(和System.Net.Http.dll)的版本號是4.6.24705.1。

我從頭開始了一個新的VS2017項目,添加了Facebook和MS登錄,它工作正常 - 讓我登錄沒有陷阱。該DLL是相同的版本。

兩個相比較的csproj文件顯示(與系統DLL沒有)的差異,但沒有明顯的:

Differences in csproj file

+0

你能分享一下項目文件中的差異嗎?有可能某些東西會傳遞地引用這個程序集。 – mlorbetske

+0

添加了csproj diffs的屏幕截圖。 – GarDavis

回答

25

什麼解決了這個問題對我來說是添加的NuGet參考System.Net.Http(版本4.3.1)到新遷移的項目。 https://www.nuget.org/packages/System.Net.Http/

+1

謝謝,今天我把同樣的錯誤升級到VS2017 – Gillardo

+1

這個錯誤也打動了我們。這裏有一個關於GitHub的相關錯誤供參考:https://github.com/aspnet/JavaScriptServices/issues/487 – poke

+0

看起來他們的解決方案是添加System.Net.Http。 – Haukman

相關問題