When using the Radzen Autocomplete, very occasionally I get the following error and this causes Blazor server to hang since the error is unhandled:
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
Received hub invocation: InvocationMessage { InvocationId: "", Target: "OnRenderCompleted", Arguments: [ 13, ], StreamIds: [ ] }.
Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher: Debug: Received hub invocation: InvocationMessage { InvocationId: "", Target: "OnRenderCompleted", Arguments: [ 13, ], StreamIds: [ ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
Received hub invocation: InvocationMessage { InvocationId: "", Target: "BeginInvokeDotNetFromJS", Arguments: [ 5, , DispatchEventAsync, 1, [{"eventHandlerId":4,"eventName":"keydown","eventFieldInfo":{"componentId":16,"fieldValue":""}},{"key":"N","code":"KeyN","location":0,"repeat":false,"ctrlKey":false,"shiftKey":true,"altKey":false,"metaKey":false,"type":"keydown"}] ], StreamIds: [ ] }.
Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher: Debug: Received hub invocation: InvocationMessage { InvocationId: "", Target: "BeginInvokeDotNetFromJS", Arguments: [ 5, , DispatchEventAsync, 1, [{"eventHandlerId":4,"eventName":"keydown","eventFieldInfo":{"componentId":16,"fieldValue":""}},{"key":"N","code":"KeyN","location":0,"repeat":false,"ctrlKey":false,"shiftKey":true,"altKey":false,"metaKey":false,"type":"keydown"}] ], StreamIds: [ ] }.
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Radzen.Debouncer.Debounce(Int32 interval, Func1 action) at Radzen.RadzenComponent.Debounce(Func
1 action, Int32 milliseconds)
at Radzen.Blazor.RadzenAutoComplete.OnFilterKeyPress(KeyboardEventArgs args)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Radzen.Debouncer.Debounce(Int32 interval, Func1 action) at Radzen.RadzenComponent.Debounce(Func
1 action, Int32 milliseconds)
at Radzen.Blazor.RadzenAutoComplete.OnFilterKeyPress(KeyboardEventArgs args)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit '_pQVnU2CgahM5fome_y4ZbfT7Qzhu_IIbggqJxz_UKM'.
System.NullReferenceException: Object reference not set to an instance of an object.
at Radzen.Debouncer.Debounce(Int32 interval, Func1 action) at Radzen.RadzenComponent.Debounce(Func
1 action, Int32 milliseconds)
at Radzen.Blazor.RadzenAutoComplete.OnFilterKeyPress(KeyboardEventArgs args)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit '_pQVnU2CgahM5fome_y4ZbfT7Qzhu_IIbggqJxz_UKM'.
System.NullReferenceException: Object reference not set to an instance of an object.
at Radzen.Debouncer.Debounce(Int32 interval, Func1 action) at Radzen.RadzenComponent.Debounce(Func
1 action, Int32 milliseconds)
at Radzen.Blazor.RadzenAutoComplete.OnFilterKeyPress(KeyboardEventArgs args)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
dbug: Microsoft.AspNetCore.SignalR.HubConnectionHandler[6]
OnConnectedAsync ending.
Microsoft.AspNetCore.SignalR.HubConnectionHandler: Debug: OnConnectedAsync ending.
This is my implementation:
<RadzenAutoComplete Value=@EntityName
Change=@OnChange
Data=@Ass?.GalleryBasicsVms
TextProperty="PageName"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
Placeholder="@(Localizer["Select a gallery"] + "...")"
Style="width: 32.5rem; max-width: 100%; display: flex; justify-content: right"
class="menuWithClose" />
void OnChange(dynamic args)
{
EntityName = args;
if (Ass.CurrentPageTypeId == 7)
{
DisplayedEvents.Clear();
if (Ass.EventBasicsVms != null)
{
if (!string.IsNullOrEmpty(EntityName))
{
DisplayedEvents.AddRange(Ass.EventBasicsVms.Where(x => x.EventName == EntityName));
}
else
{
DisplayedEvents.AddRange(Ass.EventBasicsVms);
}
}
SendEventSearchResults();
}
else if (Ass.CurrentPageTypeId == 4)
{
DisplayedGalleries.Clear();
if (Ass.GalleryBasicsVms != null)
{
if (!string.IsNullOrEmpty(EntityName))
{
DisplayedGalleries.AddRange(Ass.GalleryBasicsVms.Where(x => x.PageName == EntityName));
}
else
{
DisplayedGalleries.AddRange(Ass.GalleryBasicsVms);
}
}
SendGallerySearchResults();
}
}
I will put a try catch in the OnChange method but thought you may like to know.