Hi,
I have the following error in the Change event of a DropDownDataGrid:
Error: System.InvalidOperationException: The ParameterView instance can no longer be read because it has expired. ParameterView can only be read synchronously and must not be stored for later use.
at Radzen.ParameterViewExtensions.DidParameterChange[T](ParameterView parameters, String parameterName, T parameterValue)
at Radzen.DataBoundFormComponent`1.SetParametersAsync(ParameterView parameters)
at Radzen.DropDownBase`1.SetParametersAsync(ParameterView parameters)
at Radzen.Blazor.RadzenDropDownDataGrid`1.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
This started happening after version 5.3.5.
Any ideas?
Thanks,
Mike
enchev
October 30, 2024, 3:49pm
2
Any idea where/how to replicate this error?
UPDATE: There is already reproduction code here:
I finaly did it)
Code:
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12">
<RadzenLabel Text="Select Value" Component="DropDownDataGridTextValueProperties" />
<RadzenDropDownDataGrid @bind-Value=@customer Data=@customers TextProperty="@nameof(Customer.CompanyName)"
AllowVirtualization=true AllowFiltering=false PagerAlwaysVisible=false Name="DropDownDataGridText…
We will release update tomorrow!
Hi -
Just checking if this is fixed - I'm still getting the error.
The ParameterView instance can no longer be read because it has expired.
If this can be solved some other way in my own code, let me know.
Thanks,
Mike
enchev
November 4, 2024, 9:56pm
4
We believe this is fixed - check what version you are using.
Yes, I updated to latest version 5.5.3 to test it.
Mike
enchev
November 4, 2024, 10:01pm
6
Let us know how to replicate the problem using latest version.
Unfortunately as this is very flaky behaviour caused by render timings I do not have a reproduction but I can pinpoint the problematic code:
In SetParametesAsync, the parameters may no longer may accessed after any async call is awaited as they may be invalidated during that time. (https://stackoverflow.com/questions/66717054/the-parameterview-instance-can-no-longer-be-read-because-it-has-expired-paramet )
The error message spefically states that the parameters must only be accessed synchronously.
In DataBoundFormComponent however, if data has changed, OnDataChanged is awaited before the parameters are accessed by DidParameterChange and a subsequent call to base.SetParametersAsync. (radzen-blazor/Radzen.Blazor/DataBoundFormComponent.cs at 68f87db33e54ab3f84053394cfce893e0ca76796 · radzenhq/radzen-blazor · GitHub )
This causes a race condition.
To fix this, the if (dataChanged) { ... } can be moved after base.SetParametersAsync.
MudBlazor experienced a similar problem due to the same issue:
opened 10:23PM - 13 Mar 24 UTC
closed 10:44AM - 18 Apr 24 UTC
### Bug type
Component
### Component name
MudTreeView
### What happened?
``… `
************** Exception Text **************
System.InvalidOperationException: The ParameterView instance can no longer be read because it has expired. ParameterView can only be read synchronously and must not be stored for later use.
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target)
at MudBlazor.MudTreeViewItem`1.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
at Microsoft.AspNetCore.Components.WebView.IpcSender.<>c__DisplayClass12_0.<NotifyUnhandledException>b__1()
at Microsoft.AspNetCore.Components.WebView.WindowsForms.WindowsFormsDispatcher.InvokeAsync(Action workItem)
at Microsoft.AspNetCore.Components.WebView.WindowsForms.WindowsFormsDispatcher.<>c.<.cctor>b__8_0(Exception exception)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
```
### Expected behavior
The components should works well, because before v6.15 everything was fine.
### Reproduction link
-
### Reproduction steps
1.
2.
3.
...
### Relevant log output
_No response_
### Version (bug)
6.15.0
### Version (working)
6.14.0
### What browsers are you seeing the problem on?
Other
### On what operating system are you experiencing the issue?
Windows
### Pull Request
- [ ] I would like to do a Pull Request
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@enchev would you mind taking another look at this issue? It is unfortunately currently holding up development for us.
enchev
June 17, 2025, 9:24am
10
I’m still not sure how to reproduce this. Do you have runnable example? We accept also pull requests!
I'll create a PR then, thanks.
I have created a PR that should resolve this issue:
master
← vincentscode:fix-set-parameters-async-stale-parameters
opened 09:49AM - 17 Jun 25 UTC
Fixes: https://forum.radzen.com/t/the-parameterview-instance-can-no-longer-be-re… ad-because-it-has-expired/18912/7
See also: https://stackoverflow.com/questions/66717054/the-parameterview-instance-can-no-longer-be-read-because-it-has-expired-paramet
Thanks for the quick review and merge! Is there any timeline for the release that will include this fix?
enchev
June 23, 2025, 7:45am
15
It will be part of our update later today.
1 Like