2012-11-08 22 views
1

我得到这个异常,删除我的项目中的设置后。这是使用ProjectName.Properties命名空间的默认设置。另外我从项目中删除了app.config。 为什么我这样做:我已经添加序列化来阅读我的settings.xml而不是旧版本。XamlParseException删除设置后(app.config)

我认为这些设置是在某个地方定义的,但不知道它。

这是例外的文本,如果它可以帮助(翻译成谷歌翻译):

调用构造函数的类型“GnomeExtractor.MainWindow”,满足指定绑定约束,导致了异常“行。数字 “6”,并在 “9”。

位置我手动删除这些文件

个Settings.settings
Settings.Desighner.cs
的app.config

我MainWindow.xaml代码:

<Window ResxExtension.DefaultResxName="GnomeExtractor.Windows.MainWindow" Language="{UICulture}" 
     x:Class="GnomeExtractor.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:local="clr-namespace:GnomeExtractor" 
     xmlns:dg="http://schemas.microsoft.com/netfx/2007/xaml/presentation" 
     Title="Gnome Extractor" Height="500" Width="1000" MinHeight="500" MinWidth="1000" Loaded="Window_Loaded" Closing="Window_Closing" Icon="/GnomeExtractor;component/Resources/GX icon.ico"> 
    <Window.Resources> 
     <local:CellBackgroundColorConverter x:Key="CellBackgroundColorConverter" /> 
     <local:CellFocusableConverter x:Key="CellFocusableConverter" /> 
     <local:ColumnIndexToWidthConverter x:Key="ColumnIndexToWidthConverter" /> 
     <Style TargetType="DataGrid"> 
      <Setter Property="ItemsSource" Value="{Binding}" /> 
      <Setter Property="CanUserDeleteRows" Value="False" /> 
      <Setter Property="CanUserAddRows" Value="False" /> 
      <Setter Property="SelectionUnit" Value="Cell" /> 
      <Setter Property="RowHeaderWidth" Value="30" /> 
      <Setter Property="Margin" Value="5" /> 
      <Setter Property="SelectionMode" Value="Single" /> 
      <Setter Property="FrozenColumnCount" Value="8" /> 
      <Setter Property="MaxColumnWidth" Value="45" /> 
      <Setter Property="CanUserResizeColumns" Value="False" /> 
      <Setter Property="CanUserResizeRows" Value="False" /> 
     </Style> 
     <Style TargetType="DataGridColumnHeader"> 
      <Setter Property="ToolTip" Value="" /> 
      <EventSetter Event="ToolTipOpening" Handler="DataGridColumnHeaderProfessions_ToolTipOpening" /> 
      <Setter Property="VerticalContentAlignment" Value="Bottom" /> 
      <Setter Property="HorizontalContentAlignment" Value="Center" /> 
      <Setter Property="ContentTemplate"> 
       <Setter.Value> 
        <DataTemplate> 
         <TextBlock Text="{Binding}" Margin="5"> 
          <TextBlock.LayoutTransform> 
           <RotateTransform Angle="-90" /> 
          </TextBlock.LayoutTransform> 
         </TextBlock> 
        </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
     <Style TargetType="DataGridCell"> 
      <Setter Property="Background"> 
       <Setter.Value> 
        <MultiBinding Converter="{StaticResource CellBackgroundColorConverter}" Mode="OneWay"> 
         <Binding Path="Row[4]" /> 
         <Binding Path="Row[5]" /> 
         <Binding RelativeSource="{RelativeSource Self}" Path="Column.Header" /> 
        </MultiBinding> 
       </Setter.Value> 
      </Setter> 
      <Setter Property="Foreground" Value="Black" /> 
      <Setter Property="Focusable" Value="{Binding Converter={StaticResource CellFocusableConverter}, RelativeSource={RelativeSource Self}, Path=Column.Header}"/> 
      <EventSetter Event="PreviewMouseDown" Handler="DataGridCell_PreviewMouseDown" /> 
     </Style> 
     <Style TargetType="DataGridRowHeader"> 
      <EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridRowHeader_PreviewMouseLeftButtonDown" /> 
     </Style> 
     <Style TargetType="Image"> 
      <Style.Triggers> 
       <Trigger Property="IsEnabled" Value="False"> 
        <Setter Property="Opacity" Value="0.25" /> 
       </Trigger> 
      </Style.Triggers> 
     </Style> 
    </Window.Resources> 

如果我删除,我得到了第5行的错误了,但下代码是我的风格,我可以悄悄地删除它,并没有任何效果。

我已经回滚我的项目工作版本,并得到了当我删除的app.config

UPD此错误:我的主窗口构造函数的工作代码

public MainWindow() 
{ 
    // При первом запуске выставляем культуру установленную в компе, при последующих - предыдущую 
    // First run changing localization same like in computer 
    if (Settings.Default.ProgramLanguage == "") 
    { 
     string lang = "en-US"; 
     if (CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru") 
      if (File.Exists("ru-RU\\GnomeExtractor.resources.dll")) lang = "ru-RU"; 

     CultureManager.UICulture = new CultureInfo(lang); 
     Settings.Default.ProgramLanguage = lang; 
    } 
    else 
     CultureManager.UICulture = new CultureInfo(Settings.Default.ProgramLanguage); 

    CultureManager.UICultureChanged += new EventHandler(CultureManager_UICultureChanged); 
    resourceManager = new ResourceManager("GnomeExtractor.Resources.Loc", Assembly.GetExecutingAssembly()); 

    //if (!File.Exists("loclib.dll")) MessageBox.Show("File loclib.dll not found, please reinstall the program"); 
    //if (!File.Exists("Gnomoria.exe")) MessageBox.Show("File Gnomoria.exe not found, please install the program in game folder"); 

    InitializeComponent(); 

    UpdateLanguageMenus(); 

    //Загружаем настроечки с прошлого запуска 
    //Loading settings 
    this.WindowState = Settings.Default.LastRunWindowState; 
    this.Left = Settings.Default.LastRunLocation.X; 
    this.Top = Settings.Default.LastRunLocation.Y; 
    this.Width = Settings.Default.LastRunSize.Width; 
    this.Height = Settings.Default.LastRunSize.Height; 
    this.isCheatsOn = Settings.Default.LastRunCheatMode; 
    this.isLabelsVertical = Settings.Default.LastRunIsLablesVertical; 
    this.tabControl.SelectedIndex = Settings.Default.TabItemSelected; 
    this.isAutoUpdateEnabled = Settings.Default.IsAutoUpdateEnabled; 

    ControlStates(); 
} 

小解释:语言= {UICulture} +绑定到{Resx值}(XAML)和CultureManager类(C#代码)是使用Resx文件进行本地化的库。
UpdateLanguageMenus()和ControlStates()仅用于IsEnable控件。

删除这些文件后,我替换了所有Settings.Default。我的新类的设置(使用XML序列化),只是添加该代码

// Read settings from Xml file 
settings.ReadXml(); 

/UPD

如果您需要了解更多信息,问我,请。

+0

你确定这是造成这个错误吗? MainWindow xaml中的第6行第9行是什么? – Silvermind

+0

我为你更新了这篇文章 – DanchiZZ

+0

你可以在MainWindow.xaml的构造函数中发布代码吗?CS以及更多的你的XAML? – nmaait

回答