Xamarin.forms: [Bug] Forms 4.2 breaks hot reload

Created on 25 Sep 2019  ·  22Comments  ·  Source: xamarin/Xamarin.Forms

Description

On android:
After upgrading to 4.2.0.815419 (or any 4.2 version), I'm getting the following output when saving a xaml file with hot reload turned on
Xamarin.Forms.Xaml.XamlParseException: Position 1:1533. An element with the name "_punchCard" already exists in this NameScope.
HR seems to still work for very simple pages, but pages with more complex runtime elements seem broken after the new ui is reloaded from the changes - probably caused by these exceptions not allowing further ui loading logic to occur.

Similarly this issue also seems to break another hot reload package: https://github.com/AndreiMisiukevich/HotReload

Repro namescope output

Create a new forms project, assign the label an x:Name, turn on Hot Reload in the settings - and you should see the output when saving xaml changes:
"An element with the name "_myControlName" already exists in this NameScope."

Work-Around

downgrading to Forms 4.1 solves the issue

external-hotreload needs-info ❓ bug

Most helpful comment

When does this get released? , how do I update ?

All 22 comments

please provide a sample project, and the version of XF4.2 you're using. thanks

@StephaneDelcroix updated the description.
It's fairly easy to reproduce the namescope error output - but for simple UI, the hot reload will still work.
More difficult (and time consuming) to put together a UI that breaks because of it. My hope was that the namescope error would point out the problem in the plumbing ;)

It's fairly easy to reproduce the namescope error output

please do it then :)

It's fairly easy to reproduce the namescope error output

please do it then :)

see description for steps. You actually want me to create a new project, name a UI element and attach it here?

You actually want me to create a new project, name a UI element and attach it here?

yes, please, and also report the XF 4.2 version you're using

and also isolate the other problem, so we can focus on fixing it

I've recreated this here (https://github.com/paul-charlton/IssueSandbox/tree/XF_HotReloadAndNames), but using an iOS simulator. Is it worth raising another Issue, or just keep with this one?

Run with Hot Reload, change the label text, error appears. Output from Debug window:
[HotReload] (2019-10-01 13:52:33.8): INFO: HotReload: Initialized Agent.
[HotReload] (2019-10-01 13:52:37.3): INFO: Hot Reload Connected and Ready.
[HotReload] (2019-10-01 13:52:39.2): INFO: Xaml Changed for 'Views/SomePage.xaml' in 'IssueSandbox', sending to app...
[HotReload] (2019-10-01 13:52:40.6): WARN: Couldn't find correlation for telemetry event
Thread started: #7
[HotReload] (2019-10-01 13:52:43.7): INFO: Reloaded: 'ReloadChange in Views/SomePage.xaml', ignoring 1 unsupported edits:
[HotReload] (2019-10-01 13:52:43.7): INFO: In Views/SomePage.xaml:
[HotReload] (2019-10-01 13:52:43.7): INFO: 12:17 to 12:-1 - Position 12:17. An element with the name "NamedLabel" already exists in this NameScope

Thanks @paul-charlton ! I've been meaning to get to an upload - but stuck with tasks that put food on the table. imo it's the same issue, so belongs here.

The joys of waiting for an ios build!

I've also been getting that error

An element with the name "SomeLabelName" already exists in this NameScope

With XF 4.2.0.778463 in VS 16.3.0. If I turn off HotReload and restart VS, the errors go away.

Same here, it happens on Andrei's HotReload too.

I have the same issue.
Did someone find a solution?

I think I fixed this already, either in HR or XF, have to double check now that we have a repro

I Can't downgrade to a lower version.
Got the following Error: Package restore failed

Great to hear. Can you please confirm if it is a fix on XF or HR itself? I still use community HotReload for other IDEs and this info is important.

this is fixed in the version of HR that will be released next.

When does this get released? , how do I update ?

Not sure if "release next" has been released yet, but my hot reload seems to work now, with a small proviso: You need to turn off "break on all exceptions" in exception settings, and the hot reload still results in these false errors:
image

I have the same issue in XF 4.3.0.

This is still happening in the latest released version.

This is still happening in XF 4.3.0. What specific release version are we talking about here for the fix?

I still have this problem too. Above is says it will be in the latest hot reload update, but I'm not sure where that is released to.

This seems to be fixed for me after updating VS to 16.4.0. I'm not exactly sure if that's when it started working, but I tried it after the update and I have no problems now!

Was this page helpful?
0 / 5 - 0 ratings