ArgumentNullException when dynamically adding/removing root components from BlazorWebView #27171
Labels
area-blazor
Blazor Hybrid / Desktop, BlazorWebView
platform/windows 🪟
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
While trying to dynamically swap components into an already loaded BlazorWebView I stumbled upon an ArgumentNullException preventing me from altering webview components.
This error is triggered in BlazorWebViewHandler.cs line 119-120. NotifyCollectionChangedEventArgs NewItems/OldItems properties values are casted to RootComponent type regardless of the action operated on the collection.
But the NewItems property will be null when we remove an existing element and OldItems null when we add a new one.
Steps to Reproduce
MainPage.xaml
, put the BlazorWebView in a StackLayout, give BlazorWebView a size, and add a Button with a Click event like so:MainPage.xaml.cs
code behind implement Click event handler like so:Result: ArgumentNullException is thrown and BlazorWebView component is still displayed
Link to public reproduction project repository
No response
Version with bug
8.0.71 SR7.1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
windows 10.0.19041.0
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: