This JsonSerializerOptions instance is read-only

Hi,

I'm using the Scheduler component with a UrlAdaptor DataManager to fetch schedule data from my API.

I can see the request correctly hitting my controller and returning the correct payload, which is then rendered on the calendar correctly. However if I try to change the month/date/view the application throws the following exception:

Unhandled exception rendering component: This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization.

I've replicated this in a dotnet 8 project with the Blazor Web App project template using wasm interactive mode, using code from documentation.

Any help would be appreciated, sorry if I've just missed something!



Full exception:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

      Unhandled exception rendering component: This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization.

System.InvalidOperationException: This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization.

   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_SerializerOptionsReadOnly(JsonSerializerContext context)

   at System.Text.Json.JsonSerializerOptions.VerifyMutable()

   at System.Text.Json.JsonSerializerOptions.ConverterList.OnCollectionModifying()

   at System.Text.Json.Serialization.ConfigurationList`1[[System.Text.Json.Serialization.JsonConverter, System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]].Add(JsonConverter item)

   at Syncfusion.Blazor.Data.HttpHandler.PrepareRequest(RequestOptions options)

   at Syncfusion.Blazor.DataManager.<ExecuteQuery>d__156`1[[SchedulerTest.Client.Pages.Counter.AppointmentData, SchedulerTest.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

   at Syncfusion.Blazor.DataManager.<ExecuteQuery>d__154`1[[SchedulerTest.Client.Pages.Counter.AppointmentData, SchedulerTest.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

   at Syncfusion.Blazor.Schedule.Internal.EventBase`1.<RefreshDataManager>d__24[[SchedulerTest.Client.Pages.Counter.AppointmentData, SchedulerTest.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

   at Syncfusion.Blazor.Schedule.Internal.EventBase`1.<RefreshDataManager>d__24[[SchedulerTest.Client.Pages.Counter.AppointmentData, SchedulerTest.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

   at Syncfusion.Blazor.Schedule.Internal.VerticalView`1.<OnParametersSetAsync>d__69[[SchedulerTest.Client.Pages.Counter.AppointmentData, SchedulerTest.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)



10 Replies 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team December 4, 2023 01:54 PM UTC


Hi Dan,


Greetings from Syncfusion.


Before proceeding further with your requirement. kindly share us the below details from your end.


  1. Share us the current Nuget version used at your end.
  2. Share us whether you are facing this issue after Nuget upgrade?. If so please share us the previously used Nuget version to validate further.
  3. I've replicated this in a dotnet 8 project with the Blazor Web App project template using wasm interactive mode, using code from documentation. -> kindly share us the documentation link. So that we will try to replicate the same at our end.
  4. Or if possible share us a simple issue reproduceable sample.


The above requested details will be very helpful for us to validate your requirement.


Regards,

Monisha





DA Dan December 4, 2023 02:37 PM UTC

Hi,

Thanks for the response.

I'm using version 23.2.6 of the Nuget libraries, this is the first time I've used the scheduler component so I've not ever had a working version.


I've pushed a reproduceable sample to this repository: https://github.com/Ditchboo/SchedulerTest


The DataManager should make a post request to the simple "SchedulerController" which just returns a hardcoded event. You should see this event is shown correctly on the scheduler but if you try to change date then the JsonSerializerOptions exception is thrown.


I'm basing my example on the documentation here. Hope that helps, please let me know if you need any more information.




VS Venkateshwaran Saravanakumar Syncfusion Team December 6, 2023 03:01 PM UTC

Hi Dan,

Sample: https://github.com/SyncfusionExamples/blazor-scheduler-crud-using-url-adaptor

We have tried to replicate the mentioned issue by running the sample you provided, but we were unable to find any controller codes for the CRUD actions you used in the URL adaptor for the scheduler. Could you please share a runnable sample so that we can validate further? For your reference, we have shared a runnable sample of the URL adaptor. Kindly check that, as it might help you identify the cause and resolve the issue or try to replicate the issue in the shared sample.


Regards,

Venkatesh



DA Dan December 7, 2023 09:25 AM UTC

Hi,

Thanks for the sample, I've update my example of the issue in the repository here: https://github.com/Ditchboo/SchedulerTest this now includes the in-memory datastore and controller methods as per the sample code.


This example should run showing 2 events on the calendar, if you try to change dates then the  JsonSerializerOptions exception is thrown.


Hope that helps.

Thanks,

Dan



VS Venkateshwaran Saravanakumar Syncfusion Team December 11, 2023 04:35 PM UTC

Dan,

We are unable to run the sample you provided in the given repository and are encountering errors (The program '' has exited with code 4294967295 (0xffffffff). The program '[31600] SchedulerTest.exe' has exited with code 4294967295 (0xffffffff)). Therefore, could you please guide us on resolving the issue and running the sample? Alternatively, if you could reproduce the issue in our shared sample where we have not faced the mentioned issue on navigating through the views, it would help us validate further and provide a proper solution.



Attachment: BlazorSchedulerUrlAdaptor_363ae9ed.zip


DA Dan December 11, 2023 05:06 PM UTC

Hi,

Sorry that the sample isn't working for you.


I've recreated the issue on your shared sample by updating the Syncfusion NuGet packages to their latest versions.

    <PackageReference Include="Syncfusion.Blazor.Data" Version="23.2.7" />

    <PackageReference Include="Syncfusion.Blazor.Schedule" Version="23.2.7" />

    <PackageReference Include="Syncfusion.Blazor.Themes" Version="23.2.7" />


I've pushed this to a fork of the sample repository here.


Thanks,
Dan



VS Venkateshwaran Saravanakumar Syncfusion Team December 14, 2023 10:09 AM UTC

Dan,

We have already confirmed the problem you reported regarding "Unhandled exception rendering component: This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization" as a bug and have logged a defect report. The fix for this defect will be included in our upcoming Volume 4 release, which is expected to be rolled out on December 18, 2023. You can track the status of the fix using the following link.

Feedback: https://www.syncfusion.com/feedback/49182/exception-throws-while-performing-crud-operation-in-odatav4


Regards,
Venkatesh



SK Satheesh Kumar Balasubramanian Syncfusion Team December 19, 2023 04:06 PM UTC

Hi Dan,

 

We are glad to announce that our Essential Studio 2023 Volume 4 release v24.1.41 is rolled out and is available for download under the following link.

 

Essential Studio 2023 Volume 4 Main Release v24.1.41 is available for download | Announcements Forums | Syncfusion


The fix for the issue Unhandled exception rendering component: This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization has been included in our volume 4 release v24.1.41. Upgrade to the latest version to resolve the issue.


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Satheesh


Marked as answer

DA Dan December 19, 2023 04:40 PM UTC

Thank you, tested and working in this release.



SK Satheesh Kumar Balasubramanian Syncfusion Team December 20, 2023 06:25 AM UTC

Hi Dan,

Thanks for the update.

We are happy that your problem has been resolved now.

Regards,
Satheesh Kumar B

Loader.
Up arrow icon