I’ve got a Razor Component running on Blazor WASM. It sends an asynchronous request to the IoT device to get data type of some node. If it isn’t the same as the stored one, I’ll ask the user to update data type in a pop-up window. I’m using BlazorBootstrap.ConfirmDialog for the popup. The issue I’m facing is that after making an async request to the device, a ConfirmDialog pops up with opacity: 0;
and if I manually remove it and click any button, I’m getting
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at BlazorBootstrap.BlazorBootstrapComponentBase.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
Here is my method from razor.cs
file.
private async Task CheckFilledItemAddress(DeviceItem item)
{
var node = await NetworkingService.CallServiceAsync<IOpcBrowserService, OpcBrowseNode>(
(x) => x.GetNodeByAddressAsync(new()
{
Device = Device,
Address = item.Address
}));
if (node != null)
{
var title = "Update data type?";
var message = "Data type differs from stored one. Update data type?"
var options = new ConfirmDialogOptions
{
YesButtonText = "Ok",
NoButtonText = "Cancel"
};
return await _confirmDialog.ShowAsync(title, message, options);
}
}
I tried adding StateHasChanged();
and calling _confirmDialog.ShowAsync
in InvokeAsync
, but it didn’t help. I also tried replacing the call to GetNodeByAddressAsync
with a new object and I’m pretty sure that if I remove the async call to the IoT device, it’ll work as expected.
Old Doggo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.