I have a map setup that I am updating through the menu button. I have a strange situation when I just hit an error while creating releases. The code is as follows:
View Models
private KnownTileSource _selectedTile; public KnownTileSource SelectedTile { get { return _selectedTile; } private set { _selectedTile = value; ... OnPropertyChanged("SelectedTile"); } }
View
<Window ... xmlns:predefined="clr-namespace:BruTile.Predefined;assembly=BruTile"> ... <MenuItem Header="_Bing Aerial" Command="{Binding ChangeTileCommand}" CommandParameter="{x:Static predefined:KnownTileSource.BingAerial}" IsChecked="{Binding Path=SelectedTile, Mode=TwoWay, Converter={local:EnumToBooleanConverter}, ConverterParameter=BingAerial}"/> ... </Window>
All this worked fine in my development environment, but when I created the release build, I got the following:
Error
System.InvalidOperationException: A TwoWay or OneWay ToSource binding cannot work on the read-only property 'SelectedTile'...
A simple solution, change the private set to set in the above SelectedTile property.
So, why didn’t it throw an error during debugging and only during release? I do not see how this works in debug mode.
source share