After upgrading a project written in VS2012 against .NET 4.5 to VS2013 .NET 4.5.1 I the binding to my checkboxes throw an invalidoperation exception: A TwoWay or OneWayToSource binding cannot work on the read-only property
<CheckBox IsHitTestVisible="False" Focusable="False" Content="Invert TXD" IsChecked="{Binding EepromDataModel.InvertTxd}"/>
After adding the correct mode (OneWay) it runs fine.
Is the default bindingmode changed or is it stricter then before?
Don't get me wrong. I should have added that bindingmode before, but I was just wondering...
Edit
The Property wasn't changed. It had always a private setter. I only did the upgrade, nothing more. I have just quadruple-checked again with the code for VS2012 and there it runs fine without any exceptions thrown.
You found a security bug in the .net framework which was introduced in 4.5. Private setters should not handle the databinding of a TwoWay binding. In the following issue microsoft commented on the issue:
Connect bug two way databinding on private methods
Security update for two way binding on private methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With