xamarin/Xamarin.Forms

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

Open

#8,398 opened on Nov 6, 2019

 (7 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
a/Xaml </>e/5 :clock5:external-hotreloadhelp wantedinactivet/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide