如何在myapp.exe.config文件中停止双重条目? [英] How do I stop double-entries in the myapp.exe.config file?

查看:75
本文介绍了如何在myapp.exe.config文件中停止双重条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标准的WPF应用程序,我正在Windows 10上开发和运行。我使用设置设计器创建了几个设置,一个是用户范围的,一个是应用程序范围的。



'顶级'WPF项目名为'MyApp.WPF',它被设置为程序集名称和默认名称空间。当我查看MyApp.exe.config文件时,我发现每个设置都有两个条目,如下所示:



I have a standard WPF application which I am developing and running on Windows 10. I have used the Settings Designer to create a couple of settings, one user-scoped and one application-scoped.

The 'top-level' WPF project is called 'MyApp.WPF' and this is set as both the assembly name and default namespace. When I look in the MyApp.exe.config file, I find each setting has two entries, like this:

<applicationSettings>
    <MyApp.WPF.Properties.Settings>
        <setting name="SettingOne" serializeAs="String">
            <value>ABC</value>
        </setting>
    </MyApp.WPF.Properties.Settings>
    <MyApp.WPF>
        <setting name="SettingOne" serializeAs="String">
            <value>ABC</value>
        </setting>
    </MyApp.WPF>
</applicationSettings>

<userSettings>
    <MyApp.WPF.Properties.Settings>
        <setting name="SettingTwo" serializeAs="String">
            <value>DEF</value>
        </setting>
    </MyApp.WPF.Properties.Settings>
    <MyApp.WPF>
        <setting name="SettingTwo" serializeAs="String">
            <value>DEF</value>
        </setting>
    </MyApp.WPF>
</userSettings>





据我所知,第二个条目(具有较短'MyApp.WPF'命名空间的条目)似乎完全是多余的。这不是问题,但我想删除它,如果我可以,或者至少理解为什么它在那里。



有没有人遇到过这个? br />


我尝试了什么:



我试过更改用户设置在运行时,这会在/%Username%/MyApp/.../user.config文件中创建预期的条目,但这不能帮助我理解主要的MyApp.exe.config文件在应用程序根目录。



As far as I can tell, the second entry (the one with the shorter 'MyApp.WPF' namespace) seems to be entirely redundant. This is not a problem, but I would like to remove it if I can, or at the very least understand why it is there.

Has anyone encountered this?

What I have tried:

I have tried changing the user setting at runtime, and this creates the expected entry in the /%Username%/MyApp/.../user.config file, but this doesn't help me understand what is going on with the main MyApp.exe.config file in the application root directory.

推荐答案

最后,只有'nuke'方法似乎解决了这个问题。



我完全删除了设置文件,关闭了Visual Studio,删除了所有 \obj \bin 文件夹,然后重新启动。现在,这会在 MyApp.exe.config 文件中生成单个值。



我认为整个系统可能因为我试图将自己的文件夹和命名空间用于设置文件。 MSDN确实说设置必须在 \Properties 项目文件夹或根文件夹中(应用程序设置
In the end, only the 'nuke' approach seemed to fix this.

I deleted the settings file completely, closed Visual Studio, deleted all \obj and \bin folders, and started again. This now produces single values in the MyApp.exe.config file.

I think the whole system may have become confused by the fact that I attempted to use my own folder and namespace for the settings files. MSDN does say that the settings must be either in the \Properties project folder or the root folder ( Application Settings ).


这篇关于如何在myapp.exe.config文件中停止双重条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆