我有一个简单的AspNet Core3.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
。
[nu]是Microsoft.AspNetCore.Razor.Runtime
,但其版本为2.2.0
。无论如何,安装似乎没有帮助。
这是一个已知问题。您可以跟踪相关的线程here和here。那是因为您更新了NuGet软件包,但尚未安装3.1.1运行时。
所以您可以尝试以下两种方式:
Microsoft.AspNetCore.Authentication.AzureADB2C.UI
降级为3.1.0
Microsoft.AspNetCore.Authentication.AzureADB2C.UI
版本3.1.1
但升级到SDK 3.1.101
参考:3.1.101
使用https://github.com/dotnet/aspnetcore/issues/18334#issuecomment-581183460似乎可以解决问题。
我尚未调查原因。