删除设置后的XamlParseException(app.config)

时间:2021-02-08 14:11:51

I get that exception, after deleting settings in my project. It is a default settings that using ProjectName.Properties namespace. Also i deleted app.config from project. Why i did that: i have been added serialize for reading my settings.xml instead of the old version.

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

I think these settings are defined somewhere, but dont know it.

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

This is text of exception, if it helps (translated in google translate):

这是例外文本,如果它有帮助(翻译在谷歌翻译):

Call the constructor for type" GnomeExtractor.MainWindow ", satisfying the specified binding constraints, led to an exception." Row number "6" and the position in the "9."

调用类型“GnomeExtractor.MainWindow”的构造函数,满足指定的绑定约束,导致异常。“行号”6“和”9“中的位置。

I deleted these files manually:

我手动删除了这些文件:

Settings.settings
Settings.Desighner.cs
app.config

Settings.settings Settings.Desighner.cs app.config

My MainWindow.xaml code:

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

If i delete this, i got error in row 5 now, but next code is my styles and i can quietly delete this and it did not has no effect.

如果我删除这个,我现在在第5行得到错误,但下一个代码是我的样式,我可以悄悄地删除它,它没有任何影响。

I have rolled back my project to working version, and got this error when i delete app.config

我已将我的项目回滚到工作版本,并在删除app.config时出现此错误

UPD: My MainWindow constructor's worked code

UPD:我的MainWindow构造函数的工作代码

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();
}

Little explanation: Language={UICulture} + binding to a {Resx value} (XAML) and CultureManager class (C# code) is a lib for localization, using Resx files.
UpdateLanguageMenus() and ControlStates() just for a IsEnable controlling.

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

After deleting these files i replaced all of Settings.Default. to my new class of settings (using XML serialization) and just added this code

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

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

/UPD

If you need more information, ask me about, please.

如果您需要更多信息,请向我询问。

1 个解决方案

#1


0  

Woot, i found a problem, this is a good advice: https://*.com/a/7857728/1808239

Woot,我发现了一个问题,这是一个很好的建议:https://*.com/a/7857728/1808239

My settings.Fields.ProgramLanguage was a null, but not a ""

我的settings.Fields.ProgramLanguage是null,但不是“”

#1


0  

Woot, i found a problem, this is a good advice: https://*.com/a/7857728/1808239

Woot,我发现了一个问题,这是一个很好的建议:https://*.com/a/7857728/1808239

My settings.Fields.ProgramLanguage was a null, but not a ""

我的settings.Fields.ProgramLanguage是null,但不是“”