DataBinding: incompatible data type conversion shows no reaction
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 1d 13m
- Merged PRs (30d)
- 85
Description
### .NET version
7.0
### Did it work in .NET Framework?
No
### Did it work in any of the earlier releases of .NET Core or .NET 5+?
_No response_
### Issue description
If a DataBinding is created between two properties of incompatible data types, nothing happens at runtime, so it's harder to find the causing problem.
I bind a property of a control to a property of a class via a BindingSource.
If the data types of the properties fit, everything is fine. If they doesn't fit, the setter of the property won't be reached. But there is also no exception about the problem. Neither when not-reaching the setter nor at the app start to tell be that a DataBinding problem exists.
### Steps to reproduce
Test project:
[WinFormsNetVB.zip](https://github.com/dotnet/winforms/files/14552002/WinFormsNetVB.zip)
- start the app
- click the button
- the setters of both properties of the `Foo` class will be reached
- stop the app
- change the code: in the class `Foo`, change the type of the field `_ClassB` and the property `ClassB` from `ClassB` to `ClassA`

- start the app
- click the button
- the setter of the `ClassB` property of the `Foo` class will **not** be reached. There is also no exception message.
I expect an exception that tells me, that the data bound properties are type-incompatible, either when setting the data binding (mostly at app start) or at least when the magic of data binding will be activated after changing one of the bound properties.
Contributor guide
Assessment
This issue has not been assessed yet.