referenced code: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/Internals/NameScope.cs line 21
'throw new ArgumentException("An element with the same key already exists in NameScope", nameof(name));'
It would be fantastic if the value of the 'name' variable was included in the exception. Would make it far easier to track down the duplicate name definition in nested xaml files.
This has suddenly become more important (for me at least), as the most recent Xamarin Forms upgrade causes this exception, for code that until this version worked without problem.
@MappingSteve make sure you don't have duplicate InitializeComponent() calls in your code behind. This was the cause for us: for some reason we had the call in constructor and page_appearing - which caused the crash when we upgraded.
As a matter of interest, I'm also getting this when turning on Hot Reload for Forms.
@MappingSteve make sure you don't have duplicate InitializeComponent() calls in your code behind. This was the cause for us: for some reason we had the call in constructor and page_appearing - which caused the crash when we upgraded.
I intentionally do this in my code to "reload" the page. It worked before. Maybe I shouldn't do it. But what's the alternative?
@motoko89 I think we were doing the same thing, but once this manifested, we had to remove that code, and refresh the view model that the xaml is bound to (ie: Reset the state on the view model, and the UI should update according to it's bindings)
fyi to everyone here, I logged a Hot Reload Bug that I think is linked to the recent change that's causing us to see this error https://github.com/xamarin/Xamarin.Forms/issues/7685
@MappingSteve make sure you don't have duplicate InitializeComponent() calls in your code behind. This was the cause for us: for some reason we had the call in constructor and page_appearing - which caused the crash when we upgraded.
Thx, you just saved me and hour (or 10)
Most helpful comment
As a matter of interest, I'm also getting this when turning on Hot Reload for Forms.