簡體   English   中英

安裝 Microsoft.AspnetCore.Authentication.AzureADB2C.UI 后無法加載 Microsoft.AspNetCore.Razor.Runtime

[英]Cannot Load Microsoft.AspNetCore.Razor.Runtime after installing Microsoft.AspnetCore.Authentication.AzureADB2C.UI

我有一個簡單的 AspNet Core 3.1.1 Web 應用程序,可以正常編譯和運行。 可以說,除了自定義 HTML 和 CSS 之外,這個站點是一個使用 Visual Studio 模板創建的開箱即用的項目。

唯一添加的 nuget 包是BuildWebCompiler 1.12.394 — 不是最新的,盡管我已經嘗試更新到最新的並且不會影響接下來的問題。

如果我安裝了 nuget 包Microsoft.AspNetCore.Authentication.AzureADB2C.UI 3.1.1一切都會繼續編譯。 但是,我在Startup.ConfigureServices期間遇到以下異常:

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, 
  Version=3.1.1.0, 
  Culture=neutral, 
  PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
  Source=<Cannot evaluate the exception source>
  StackTrace:<Cannot evaluate the exception stack trace>

除了 nuget 安裝之外,項目中沒有任何代碼或設置發生變化。 拋出異常的代碼是:

public void ConfigureServices(IServiceCollection services)
{
   services.AddRazorPages(); // <--- throws
   services.AddServerSideBlazor();
}

我四處探索,看到與 Core 3.1.x幾個程序集引發了這個文件未找到異常,但沒有發現特別提到Razor.Runtime

Microsoft.AspNetCore.Razor.Runtime有一個 nuget ,但它的版本是2.2.0 無論如何,安裝它似乎沒有幫助。

這是一個已知問題。 您可以在此處此處跟蹤相關線程。 這是因為您更新了 NuGet 包但尚未安裝 3.1.1 運行時。

所以你可以嘗試以下兩種方法:

  • Microsoft.AspNetCore.Authentication.AzureADB2C.UI降級到3.1.0
  • 使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI版本3.1.1但升級到SDK 3.1.101

參考: https : //github.com/dotnet/aspnetcore/issues/18334#issuecomment-581183460

使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI 3.1.0似乎可以解決問題。

我還沒有研究為什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM