更新到 netcore3.0-preview8 后 Blazor Mono 客户端错误
Blazor Mono Clientside Error after updating to netcore3.0-preview8
我已将我的 Blazor 客户端项目从预览版 7 更新到预览版 8,与 Visual Studio 2019 年一起运行。
我已按照此处详述的说明进行操作;
ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8
但是,当我构建解决方案时出现以下错误;
Fatal error in IL Linker 5> 5>Unhandled Exception:
Mono.Linker.Steps.XmlResolutionException: Failed to process XML
description: --->
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' --->
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' 5> at
Mono.Linker.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
name, ReaderParameters parameters) 5> at
Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name,
ReaderParameters parameters) 5> at
Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> --- End of
inner exception stack trace --- 5> at
Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> at
Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly)
5> at
Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies(LinkContext
context, XPathNodeIterator iterator) 5> at
Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> --- End of inner
exception stack trace --- 5> at
Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> at
Mono.Linker.Steps.BaseStep.Process(LinkContext context) 5> at
Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) 5>
at Mono.Linker.Pipeline.Process(LinkContext context) 5> at
Mono.Linker.Driver.Run(ILogger customLogger) 5> at
Mono.Linker.Driver.Execute(String[] args, ILogger customLogger) 5>
at Mono.Linker.Driver.Main(String[] args)
5>C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build.0.0-preview8.19405.7\targets\Blazor.MonoRuntime.targets(441,5):
error MSB3073: The command "dotnet
"C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/illink/illink.dll"
-l none --disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u
link -b true -d
"C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/"
-d "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/Facades/"
-o "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker/"
-x "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build.0.0-preview8.19405.7\targets\BuiltInBclLinkerDescriptor.xml"
-x "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker.descriptor.xml"
-a "C:\Users\matt.nuget\packages\blazored.localstorage.0.12\lib\netstandard2.0\Blazored.LocalStorage.dll"
-a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll"
-a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.httpclient.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.HttpClient.dll" -a "C:\Users\matt.nuget\packages\mono.webassembly.interop.0.0-preview8.19405.4\lib\netstandard2.0\Mono.WebAssembly.Interop.dll"
-a "C:\Users\matt.nuget\packages\newtonsoft.json.0.3-beta1\lib\netstandard2.0\Newtonsoft.Json.dll"
-a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Shared\bin\Debug\netstandard2.1\OakfieldLeasing.Blazor.Shared.dll"
-a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\OakfieldLeasing.Blazor.Client.dll""
exited with code -532462766.
Blazor 客户端项目引用的唯一其他项目是引用 .Net Standard 2.1
的共享项目。
我在 Blazor Client 项目的依赖项 -> 分析器中列出了以下内容。
最后我的 .csproj
是
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath></OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="2.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3-beta1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OakfieldLeasing.Blazor.Shared\OakfieldLeasing.Blazor.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>
我也试过用 Microsoft.AspNetCore.NewtonsoftJson
Nuget 包替换 Newtonsoft.Json
,但这似乎没有什么不同。
请问有人知道是什么原因造成的吗?
问题是由于误读了升级博客和文档。
博客在这里
ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8
这里又参考了Steve Sandersons的迁移步骤;
Migrate from ASP.NET Core 2.2 to 3.0
用于从 2.2 移植到 3.0,并将 .csproj 的引用替换为 <TargetFramework>netcoreapp3.0</TargetFramework>
我对客户项目做错了。这是无效的,因为 Mono WebAssembly 作为 netstandard2.0 运行,而不是 netcoreapp3.0。
将 .csproj 恢复为 netstandard2.0
解决了这个问题。
我已将我的 Blazor 客户端项目从预览版 7 更新到预览版 8,与 Visual Studio 2019 年一起运行。
我已按照此处详述的说明进行操作;
ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8
但是,当我构建解决方案时出现以下错误;
Fatal error in IL Linker 5> 5>Unhandled Exception: Mono.Linker.Steps.XmlResolutionException: Failed to process XML description: ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' 5> at Mono.Linker.DirectoryAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) 5> at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) 5> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> --- End of inner exception stack trace --- 5> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> at Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly) 5> at Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies(LinkContext context, XPathNodeIterator iterator) 5> at Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> --- End of inner exception stack trace --- 5> at Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> at Mono.Linker.Steps.BaseStep.Process(LinkContext context) 5> at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) 5>
at Mono.Linker.Pipeline.Process(LinkContext context) 5> at Mono.Linker.Driver.Run(ILogger customLogger) 5> at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger) 5>
at Mono.Linker.Driver.Main(String[] args) 5>C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build.0.0-preview8.19405.7\targets\Blazor.MonoRuntime.targets(441,5): error MSB3073: The command "dotnet "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/illink/illink.dll" -l none --disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/" -d "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/Facades/" -o "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker/" -x "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build.0.0-preview8.19405.7\targets\BuiltInBclLinkerDescriptor.xml" -x "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker.descriptor.xml" -a "C:\Users\matt.nuget\packages\blazored.localstorage.0.12\lib\netstandard2.0\Blazored.LocalStorage.dll" -a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll" -a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.httpclient.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.HttpClient.dll" -a "C:\Users\matt.nuget\packages\mono.webassembly.interop.0.0-preview8.19405.4\lib\netstandard2.0\Mono.WebAssembly.Interop.dll" -a "C:\Users\matt.nuget\packages\newtonsoft.json.0.3-beta1\lib\netstandard2.0\Newtonsoft.Json.dll" -a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Shared\bin\Debug\netstandard2.1\OakfieldLeasing.Blazor.Shared.dll" -a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\OakfieldLeasing.Blazor.Client.dll"" exited with code -532462766.
Blazor 客户端项目引用的唯一其他项目是引用 .Net Standard 2.1
的共享项目。
我在 Blazor Client 项目的依赖项 -> 分析器中列出了以下内容。
最后我的 .csproj
是
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath></OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="2.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3-beta1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OakfieldLeasing.Blazor.Shared\OakfieldLeasing.Blazor.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>
我也试过用 Microsoft.AspNetCore.NewtonsoftJson
Nuget 包替换 Newtonsoft.Json
,但这似乎没有什么不同。
请问有人知道是什么原因造成的吗?
问题是由于误读了升级博客和文档。
博客在这里
ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8
这里又参考了Steve Sandersons的迁移步骤;
Migrate from ASP.NET Core 2.2 to 3.0
用于从 2.2 移植到 3.0,并将 .csproj 的引用替换为 <TargetFramework>netcoreapp3.0</TargetFramework>
我对客户项目做错了。这是无效的,因为 Mono WebAssembly 作为 netstandard2.0 运行,而不是 netcoreapp3.0。
将 .csproj 恢复为 netstandard2.0
解决了这个问题。