Xamarin.forms: [Bug] Hot Reload & An element with the same key already exists in Namescope

Created on 6 Nov 2019  路  7Comments  路  Source: xamarin/Xamarin.Forms

Description

A File | New Xamarin Forms project with updates applied (as detailed below) causes an exception that breaks execution when CLR Exceptions are enabled

Steps to Reproduce

  1. File | New Xamarin Forms project

  2. Update the following in the csproj files:

    <PackageReference Include="Xamarin.Forms" Version="4.3.0.947036" />
    <PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
    <PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
  1. Added any element and give it a x:Name. The attached demo project has two buttons added.

  2. Enabled Hot Reload

  3. Run the application (emulator or physical device), modify the MainPage.xaml (such as the button text). Red squiggles appear under the Button elements with a tip indicating the error being reported. The application continues to run. See screen shots provided.

  4. Enable CLR exceptions and repeat step 5.

  5. An exception will be raised as provided in the attached screen shots. The application will continue to run but it interrupts debugging.

Expected Behavior

Hot Reload should reload the XAML without error.

Actual Behavior

When modifying a page with hot reload enabled an exception is raised (suppressed when CLR exceptions are not enabled)

Basic Information

  • Version with issue: Xamarin Forms 4.3.0.947036
  • Last known good version: Unknown
  • IDE: Visual Studio for Windows

Screenshots

Screen shots are included in the attached.

Reproduction Link

A demo application is attached.
NamescopeError.zip

VS bug #1158393

Xaml </> 5 external-hotreload help wanted inactive bug up-for-grabs

Most helpful comment

I was seeing the same issue as well.

All 7 comments

#

I don't think this is a duplicate of https://github.com/xamarin/Xamarin.Forms/issues/8322

My report is completely different (as far as I can tell)

I was seeing the same issue as well.

Same here. It would be really nice to have this fixed.

Same here. I am no longer using x:Name, I'm using ViewModels instead.

I avoid x:name where possible but sometimes it is just unavoidable

I avoid x:name where possible but sometimes it is just unavoidable

it's not XF bug. This is related to HR

BTW, you can try Non-official hot reload, which should work https://github.com/AndreiMisiukevich/HotReload

Was this page helpful?
0 / 5 - 0 ratings