Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Binding changed for checkbox after upgrade to VS2013 and .NET 4.5.1?

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.

like image 527
Koen Avatar asked Jan 31 '26 12:01

Koen


1 Answers

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

like image 137
Peter Avatar answered Feb 02 '26 07:02

Peter