NET 6-7 + Scheduler = Unhandled exception rendering component: The type initializer for 'System.Linq.Dynamic.Core.DynamicQueryableExtensions' threw an exception

I have just tried to use the example Blazor Scheduler | a free UI component by Radzen in my project.
Unfortunately, there is a very ugly mistake.
I'm using NET 6, Preview 7

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: The type initializer for 'System.Linq.Dynamic.Core.DynamicQueryableExtensions' threw an exception.
System.TypeInitializationException: The type initializer for 'System.Linq.Dynamic.Core.DynamicQueryableExtensions' threw an exception.
 ---> System.Exception: Specific method not found: FirstOrDefault
 ---> System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() in System.Linq.dll:token 0x6000319+0x0
   at System.Linq.Enumerable.TryGetSingle[MethodInfo](IEnumerable`1 source, Func`2 predicate, Boolean& found) in System.Linq.dll:token 0x60000d3+0x3d
   at System.Linq.Enumerable.Single[MethodInfo](IEnumerable`1 source, Func`2 predicate) in System.Linq.dll:token 0x60000cd+0x0
   at System.Linq.Dynamic.Core.DynamicQueryableExtensions.GetMethod(String name, Int32 parameterCount, Func`2 predicate) in System.Linq.Dynamic.Core.dll:token 0x60000d1+0x14
   --- End of inner exception stack trace ---
   at System.Linq.Dynamic.Core.DynamicQueryableExtensions.GetMethod(String name, Int32 parameterCount, Func`2 predicate) in System.Linq.Dynamic.Core.dll:token 0x60000d1+0x3e
   at System.Linq.Dynamic.Core.DynamicQueryableExtensions..cctor() in System.Linq.Dynamic.Core.dll:token 0x60000d2+0xe3
   --- End of inner exception stack trace ---
   at Radzen.Blazor.RadzenScheduler`1[[Sport.Models.Appointment, Sport.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetAppointmentsInRange(DateTime start, DateTime end) in Radzen.Blazor.dll:token 0x6000e24+0x63
   at Radzen.Blazor.RadzenMonthView.Render() in Radzen.Blazor.dll:token 0x6000c47+0xd
   at Radzen.Blazor.RadzenScheduler`1[[Sport.Models.Appointment, Sport.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].BuildRenderTree(RenderTreeBuilder __builder) in Radzen.Blazor.dll:token 0x6000df2+0x3e1
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder) in Microsoft.AspNetCore.Components.dll:token 0x60000a8+0xe
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) in Microsoft.AspNetCore.Components.dll:token 0x600030a+0x17
window.Module.s.printErr @ blazor.webassembly.js:1
ye._internal.dotNetCriticalError @ blazor.webassembly.js:1
ut @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.0-preview.7.21377.19.js:1
$func2545 @ 008b64c6:0x7e724
$func2270 @ 008b64c6:0x66a5e
$func6847 @ 008b64c6:0x168e10
$func6664 @ 008b64c6:0x160079
$func3456 @ 008b64c6:0xaca88
$func473 @ 008b64c6:0x10fbf
$func6299 @ 008b64c6:0x150109
$func2545 @ 008b64c6:0x7e6dd
$func2270 @ 008b64c6:0x66a5e
$func6847 @ 008b64c6:0x168e10
$func6664 @ 008b64c6:0x160079
$func3456 @ 008b64c6:0xaca88
$func666 @ 008b64c6:0x1595d
$gb @ 008b64c6:0x15cabf
Module._mono_wasm_invoke_method @ dotnet.6.0.0-preview.7.21377.19.js:1
managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_BeginInvokeDotNet @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_BeginInvokeDotNet:19
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
g @ blazor.webassembly.js:1
e.invokeMethodAsync @ blazor.webassembly.js:1
(anonym) @ blazor.webassembly.js:1
le @ blazor.webassembly.js:1
ce @ blazor.webassembly.js:1
(anonym) @ blazor.webassembly.js:1
(anonym) @ blazor.webassembly.js:1
onGlobalEvent @ blazor.webassembly.js:1
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Could not find 'Radzen.createScheduler' ('Radzen' was undefined).
      Error: Could not find 'Radzen.createScheduler' ('Radzen' was undefined).
          at https_localhost:5001/_framework/blazor.webassembly.js:1:288
          at Array.forEach (<anonymous>)
          at r.findFunction (https_localhost:5001/_framework/blazor.webassembly.js:1:256)
          at w (https_localhost:5001/_framework/blazor.webassembly.js:1:2414)
          at https_localhost:5001/_framework/blazor.webassembly.js:1:3267
          at new Promise (<anonymous>)
          at Object.beginInvokeJSFromDotNet (https_localhost:5001/_framework/blazor.webassembly.js:1:3248)
          at Object.ut [as invokeJSFromDotNet] (https_localhost:5001/_framework/blazor.webassembly.js:1:53981)
          at _mono_wasm_invoke_js_blazor (https_localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1:191287)
          at <anonymous>:wasm-function[2545]:0x7e724
Microsoft.JSInterop.JSException: Could not find 'Radzen.createScheduler' ('Radzen' was undefined).
Error: Could not find 'Radzen.createScheduler' ('Radzen' was undefined).
    at https_localhost:5001/_framework/blazor.webassembly.js:1:288
    at Array.forEach (<anonymous>)
    at r.findFunction (https_localhost:5001/_framework/blazor.webassembly.js:1:256)
    at w (https_localhost:5001/_framework/blazor.webassembly.js:1:2414)
    at https_localhost:5001/_framework/blazor.webassembly.js:1:3267
    at new Promise (<anonymous>)
    at Object.beginInvokeJSFromDotNet (https_localhost:5001/_framework/blazor.webassembly.js:1:3248)
    at Object.ut [as invokeJSFromDotNet] (https_localhost:5001/_framework/blazor.webassembly.js:1:53981)
    at _mono_wasm_invoke_js_blazor (https_localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1:191287)
    at <anonymous>:wasm-function[2545]:0x7e724
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Radzen.Blazor.RadzenScheduler`1.Rect[[Sport.Models.Appointment, Sport.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Radzen.Blazor, Version=3.9.7.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in Microsoft.JSInterop.dll:token 0x60000b3+0x154
   at Radzen.Blazor.RadzenScheduler`1.<OnAfterRenderAsync>d__91[[Sport.Models.Appointment, Sport.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in Radzen.Blazor.dll:token 0x600160f+0x103
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) in Microsoft.AspNetCore.Components.dll:token 0x6000285+0x65

Is it Blazor server-side or WebAssembly?

WebAssembly - Sorry, i missed to deliver this information.

Please add the following reference after Radzen.Blazor in your project:

<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.12" />


I've just published Radzen.Blazor 3.9.8 with this issue resolved.

1 Like

works like a charm. thank you very much

For anyone else that encounters this problem. Strangely I had this issue with 4.8.4, after manually adding the reference to the System.Linq.Dynamic.Core (1.3.0) Radzen scheduler started working again. Updated to latest nuget - all is good in the world