Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization.
I have an SfGrid that is using an OData SfDataManager. After editing a record and clicking the Save button, I get the error in the subject.
.Net 7 Blazor Server, Syncfusion 24.1.41.
Here is my Grid definition (except for the GridColumns).
<SfGrid @ref="Grid" TValue="Repair"
Query="defaultQuery"
AllowPaging="true" AllowSorting="true" AllowFiltering="true"
EnableHover="true" AllowResizing="true"
AllowExcelExport="true" Toolbar="@toolbar">
<SfDataManager Url="odata/Repairs"
Adaptor="Adaptors.ODataV4Adaptor"
HttpClientInstance="@httpClient" />
<GridPageSettings PageSizes="true" />
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.FilterBar"
Mode="FilterBarMode.Immediate">
<GridFilterColumns>
@if (customer != null)
{
<GridFilterColumn Field="@nameof(Repair.CustomerId)"
Operator="Operator.Equal"
Predicate="and"
Value="@customer.CustomerId" />
}
@if (inventoryItem != null)
{
<GridFilterColumn Field="@nameof(Repair.InventoryItemId)"
Operator="Operator.Equal"
Predicate="and"
Value="@inventoryItem.InventoryItemId" />
}
</GridFilterColumns>
</GridFilterSettings>
<GridSortSettings>
<GridSortColumns>
<GridSortColumn Field="@nameof(Repair.InDate)" Direction="SortDirection.Descending" />
</GridSortColumns>
</GridSortSettings>
<GridEditSettings Mode="EditMode.Dialog"
ShowDeleteConfirmDialog="true"
AllowAdding="true"
AllowDeleting="true"
AllowEditing="true"
Dialog="@dialogSettings">
<HeaderTemplate>Add/Edit Repair</HeaderTemplate>
</GridEditSettings>
<GridEvents TValue="Repair"
OnActionFailure="ActionFailure"
OnActionBegin="ActionBegin"
OnToolbarClick="ToolbackClicked"
CommandClicked="OnCommandClicked" />
<GridColumns>
<GridColumn Field="@nameof(Repair.RepairId)"
IsPrimaryKey="true"
IsIdentity="true"
Visible="false" />
Here is the stack trace.
This JsonSerializerOptions instance is read-only or has already been used in serialization or deserialization.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_SerializerOptionsImmutable(JsonSerializerContext context)
at System.Text.Json.JsonSerializerOptions.ConverterList.VerifyMutable()
at System.Text.Json.Serialization.ConfigurationList`1.Add(TItem item)
at Syncfusion.Blazor.Data.DataUtil.CompareAndRemove(Object data, Object original, String key)
at Syncfusion.Blazor.Data.ODataAdaptor.Update(DataManager dataManager, String keyField, Object data, String tableName, Query query, Object original, IDictionary`2 updateProperties)
at Syncfusion.Blazor.DataManager.<Update>d__163`1.MoveNext()
at Syncfusion.Blazor.Grids.Internal.DataGenerator`1.<GetData>d__22.MoveNext()
I put a break in the OData controller update method but it doesn't get that far. I can't figure out what would be causing this error. I recently converted all of my SfGrids to use the ODataV4Adapter and some grids work ok and some get this error when saving the record. Thanks for any help you can provide.
I updated the project that was previously attached to this post so it generates the error. The .zip was too large to attach to the post so I created a GitHub repository.
https://github.com/cvboucher/DemoFail
The errors occurs after editing an existing record before saving.
Thanks,
Craig
Replication Steps:
-->Please run the attached sample from the following link:
https://github.com/cvboucher/DemoFail
--->After running the sample, edit any row and click the save button to observe the issue."