dotnet / dotnet/wpf

[ .NET Hot Reload / EnC ] A failed Binding Path will always fail even after fixing it by Applying Code Changes

Open
#5,177 1 comment 0 reactions 0 assignees View on GitHub
.NET Framework
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 6.0.100-preview.7.21379.14
* Windows version: 21H1 19043.1165
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio: Not really

**Problem description:**

Once a Binding Path fails, it will always fail even when it should succeed after applying code changes (I guess failures are cached).

There is no need to use XAML to repro this, but here is a simple way to explain it using XAML:

* \

If that "MyContent" property doesn't exist on the DataContext, the Binding will fail, which makes sense. But if that "MyContent" property gets added using Hot Reload or Edit and Continue, then any new Binding that also uses the path "MyContent" will always fail even when they shouldn't.

**REPRO:**
1. Open this project in VS 16.11 or 17 latest builds:
[ConsoleApp4-Binding.zip](https://github.com/dotnet/wpf/files/7049783/ConsoleApp4-Binding.zip)
1. Build and debug that app with Edit and Continue enabled (the default)
1. Notice this dialog:
![image](https://user-images.githubusercontent.com/2523431/130861253-3e7df0f5-8bdf-4896-ab9a-c725349669d1.png)
1. In VS, in the Program.cs file, uncomment the only commented line to add a property called "BarBindToValue":
![image](https://user-images.githubusercontent.com/2523431/130861348-78c519bc-fb23-4f02-9548-17c927eedc1f.png)
1. Click OK in the dialog to re-run the binding logic

**Actual behavior:**
No change even though the new Binding("BarBindToValue") should succeed:
![image](https://user-images.githubusercontent.com/2523431/130863052-8a12f12c-cf94-49e0-916f-e8d6e9378fdc.png)

**Expected behavior:**
Both bindings should work after applying code changes and clicking OK:
![image](https://user-images.githubusercontent.com/2523431/130863108-6afd7024-1bec-45fc-918e-8303a61af179.png)

**Minimal repro:**
I'll just show the complete sample code here. The circled Bindings are the important part. The second binding will fail once, then it should succeed after applying code changes. But it will fail again:

![image](https://user-images.githubusercontent.com/2523431/130863439-c37b32d2-bb59-4443-bd87-af015aa21e93.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.