gpt4 book ai didi

Blazor .Net 6.0 热重载

转载 作者:行者123 更新时间:2023-12-04 17:08:52 26 4
gpt4 key购买 nike

我有一个 asp.net 托管的 blazor wasm 应用程序,我刚刚从 5.0 升级到 6.0。从 VS 2022 或 dotnet watch run 尝试热重载时,我在浏览器控制台中收到以下错误:

aspnetcore-browser-refresh.js:138

   Error: System.NullReferenceException: Object reference not set to an instance of an object.

在 Microsoft.AspNetCore.Components.WebAssembly.HotReload.WebAssemblyHotReload.ApplyHotReloadDelta(String moduleIdString, Byte[] metadataDelta, Byte[] ilDeta)在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder Binder ,Object[] 参数,CultureInfo 文化)--- 从上一个位置开始的堆栈跟踪结束 ---在 Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime jsRuntime、DotNetInvocationInfo& callInfo、IDotNetObjectReference objectReference、String argsJson)在 Microsoft.JSInterop.Infrastructure.DotNetDispatcher.Invoke(JSRuntime jsRuntime、DotNetInvocationInfo& invocationInfo、String argsJson)在 Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime.InvokeDotNet(String assemblyName,String methodIdentifier,String dotNetObjectId,String argsJson)在 Object._convert_exception_for_method_call (https://localhost:44362/_framework/dotnet.6.0.0.qme34vl4fz.js:1:178709)在 Object._handle_exception_for_call (https://localhost:44362/_framework/dotnet.6.0.0.qme34vl4fz.js:1:180678)在 managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet ( https://mono-wasm.invalid/managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:20:21 )在 Object.invokeDotNetFromJS (https://localhost:44362/_framework/blazor.webassembly.js?version=32330328618b4ff08635274a6f31248c:1:42078)在 g (https://localhost:44362/_framework/blazor.webassembly.js?version=32330328618b4ff08635274a6f31248c:1:1618)在 Object.e.invokeMethod (https://localhost:44362/_framework/blazor.webassembly.js?version=32330328618b4ff08635274a6f31248c:1:2665)在 Object.St.Te._internal.applyHotReload (https://localhost:44362/_framework/blazor.webassembly.js?version=32330328618b4ff08635274a6f31248c:1:56100)在 https://localhost:44362/_framework/aspnetcore-browser-refresh.js:136:33在 Array.forEach()在 applyBlazorDeltas (https://localhost:44362/_framework/aspnetcore-browser-refresh.js:134:12)

最佳答案

我必须在 UseBlazorFrameworkFiles() 之后放置 UseStaticFiltes(),否则会发生 NullReferenceException。这对我有用:

app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

关于Blazor .Net 6.0 热重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69906572/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com