-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor HotReload throws System.NullReferenceException
when using Serilog
#45536
Comments
Thanks for contacting us. Could you please provide us with a minimal repro project hosted as public GitHub repository? This will help us investigate what the root cause is. Thanks! |
Hi @tico321. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@MackinnonBuck Thanks for the quick reply. I created this project where you can reproduce the issue https://github.com/tico321/BlazorNullReferenceWithSerilog |
@MackinnonBuck can you please spend few hours to investigate this and summarize your findings as a comment? We'll decide when / how to tackle it later. |
SummaryThe root of the problem is that DetailsSince the The
WorkaroundThis can be worked around by passing the Next stepsUltimately, the specific issue at hand is a Serilog bug. From Blazor's perspective, all bets are off as soon as a library interferes with its internal state in a manner other than through the public API. That said, we could look into adding extra checks to catch this case rather than failing silently. |
The workout around works like a charm, thank you for the investigation @MackinnonBuck! |
Thanks for checking this out! Just a quick question on:
Is the Microsoft.JSInterop namespace intended to be internal/undocumented? I don't think we're relying on any nefarious reflection tricks these days :-) so it'd be great to get some indication of which API we should be steering clear of. |
Is there an existing issue for this?
Describe the bug
When using the serilog browser-console sink, the application throws
System.NullReferenceException
. The author of the library already tried to fix it but it looks like it's a problem with Blazor itself.Here is a reference to the issue in the browser-console sink repository serilog/serilog-sinks-browserconsole#20
Expected Behavior
We should be able to add a log and start the application without getting a null reference exception.
Steps To Reproduce
Exceptions (if any)
[ FTL ] An exception occurred while creating the WASM host
$(String[] args) in D:\workspace\projects\Hephaestus\src\presentation\Hephaestus.WebApp\Program.cs:line 43System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Components.WebAssembly.HotReload.WebAssemblyHotReload.InitializeAsync()
at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.RunAsyncCore(CancellationToken cancellationToken, WebAssemblyCultureProvider cultureProvider)
at Program.
(anonymous) @ blazor.webassembly.js:1
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
Gt @ blazor.webassembly.js:1
Ii @ dotnet.7.0.0.k4xetpuqcq.js:5
_mono_wasm_invoke_js_blazor @ dotnet.7.0.0.k4xetpuqcq.js:14
$func313 @ 009924a6:0x1d4a3
$func283 @ 009924a6:0x1c8d1
$func221 @ 009924a6:0xdfdd
$func220 @ 009924a6:0xce8f
$func8112 @ 009924a6:0x1a1fcc
$func2053 @ 009924a6:0x859fe
$func2058 @ 009924a6:0x86066
$func2085 @ 009924a6:0x88125
$mono_wasm_invoke_method_ref @ 009924a6:0x9bcb
Module._mono_wasm_invoke_method_ref @ dotnet.7.0.0.k4xetpuqcq.js:14
_Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS:26
endInvokeJSFromDotNet @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
Promise.then (async)
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
Gt @ blazor.webassembly.js:1
Ii @ dotnet.7.0.0.k4xetpuqcq.js:5
_mono_wasm_invoke_js_blazor @ dotnet.7.0.0.k4xetpuqcq.js:14
$func313 @ 009924a6:0x1d4a3
$func283 @ 009924a6:0x1c8d1
$func221 @ 009924a6:0xdfdd
$func220 @ 009924a6:0xce8f
$func8112 @ 009924a6:0x1a1fcc
$func2053 @ 009924a6:0x859fe
$func2051 @ 009924a6:0x85974
$func1394 @ 009924a6:0x68446
$func313 @ 009924a6:0x1d45c
$func283 @ 009924a6:0x1c8d1
$func221 @ 009924a6:0xdfdd
$func220 @ 009924a6:0xce8f
$func8112 @ 009924a6:0x1a1fcc
$func2053 @ 009924a6:0x859fe
$func2058 @ 009924a6:0x86066
$func2085 @ 009924a6:0x88125
$mono_wasm_invoke_method_ref @ 009924a6:0x9bcb
Module._mono_wasm_invoke_method_ref @ dotnet.7.0.0.k4xetpuqcq.js:14
_Hephaestus_WebApp__entrypoint @ _Hephaestus_WebApp__entrypoint:26
(anonymous) @ dotnet.7.0.0.k4xetpuqcq.js:5
ji @ dotnet.7.0.0.k4xetpuqcq.js:5
callEntryPoint @ blazor.webassembly.js:1
Vt @ blazor.webassembly.js:1
await in Vt (async)
(anonymous) @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
blazor.webassembly.js:1
---> System.NullReferenceException: Object reference not set to an instance of an object.
$(String[] args) in D:\workspace\projects\Hephaestus\src\presentation\Hephaestus.WebApp\Program.cs:line 48at Microsoft.AspNetCore.Components.WebAssembly.HotReload.WebAssemblyHotReload.InitializeAsync()
at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.RunAsyncCore(CancellationToken cancellationToken, WebAssemblyCultureProvider cultureProvider)
at Program.
--- End of inner exception stack trace ---
.NET Version
net7.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: