When using WASM Blazor with Kestrel hosting you need to reference the WASM project from the server project.
Usually it works, because the server tries not to load everything from the WASM project - in this case LiveSharp.Support.BlazorWASM.dll.
Cause
I changed the server's JsonOptions and got a TypeLoadException from Unknown Module. After some try-and-error I found that removing AddJsonOptions fixes the issue. Here's the service configuration:
I think TimeSpanConverter causes the loading of LiveSharp.Support.BlazorWASM.dll and tries to load it. But in the server project it is not copied to the output folder.-
Proper Fix (Guess)
I guess it's how the DLL gets injected by the msbuild task. It should copy transient LiveSharp dependencies from client project to server project.
Workaround
Currently the only way to fix this is to take a direct dependency to the NuGet's DLL file in .csproj-file like this:
System.TypeInitializationException: 'The type initializer for '<Module>' threw an exception.'
Inner Exception
FileNotFoundException: Could not load file or assembly 'LiveSharp.Support.BlazorWASM, Version=1.6.2.0, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
Info
LiveSharp 2.0.9 LiveSharp.Server 2.0.6
Affected Versions
LiveSharp 1.6.x (or even ealier).
Issue
When using WASM Blazor with Kestrel hosting you need to reference the WASM project from the server project.
Usually it works, because the server tries not to load everything from the WASM project - in this case
LiveSharp.Support.BlazorWASM.dll
.Cause
I changed the server's
JsonOptions
and got aTypeLoadException
fromUnknown Module
. After some try-and-error I found that removingAddJsonOptions
fixes the issue. Here's the service configuration:Root Cause
I think
TimeSpanConverter
causes the loading ofLiveSharp.Support.BlazorWASM.dll
and tries to load it. But in the server project it is not copied to the output folder.-Proper Fix (Guess)
I guess it's how the DLL gets injected by the msbuild task. It should copy transient LiveSharp dependencies from client project to server project.
Workaround
Currently the only way to fix this is to take a direct dependency to the NuGet's DLL file in .csproj-file like this:
Exception
Callstack (from Browser output)