2017-10-16 44 views
5

我有一個地圖瓷磚設置,我通過菜單按鈕更新。我遇到了一個奇怪的情況,那就是在發佈版本時只有一個錯誤。代碼如下:私人二傳手投擲錯誤只發布版本

視圖模型

private KnownTileSource _selectedTile; 
public KnownTileSource SelectedTile 
{ 
    get { return _selectedTile; } 
    private set 
    { 
     _selectedTile = value; 
     ... 
     OnPropertyChanged("SelectedTile"); 
    } 
} 

查看

<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> 

這是在我的開發環境中的所有工作正常,但是當我生成一個發佈版本我得到如下:

錯誤

System.InvalidOperationException: A TwoWay or OneWay ToSource binding cannot work on the read-only property 'SelectedTile'...

簡單的解決方案,在上述SelectedTile屬性更改private setset

那麼爲什麼在調試過程中並且僅在發佈過程中沒有拋出錯誤呢?我看不到在調試模式下這是如何工作的。

+0

剛剛遇到這個我自己。對我而言,問題在於是否將調試器連接到進程,而不是如果應用程序是以調試模式還是發佈模式構建的。 –

回答