标签: application-settings

在Windows窗体应用程序中保存应用程序设置的最佳实践

我想要实现的非常简单:我有一个Windows窗体(.NET 3.5)应用程序,它使用一个路径来读取信息.用户可以使用我提供的选项表单修改此路径.

现在,我想将路径值保存到文件中供以后使用.这将是保存到此文件的众多设置之一.该文件将直接位于应用程序文件夹中.

我理解有三种选择:

  • ConfigurationSettings文件(appname.exe.config)
  • 注册处
  • 自定义XML文件

我读到.NET配置文件没有预见到将值保存回来.至于注册表,我想尽可能远离它.

这是否意味着我应该使用自定义XML文件来保存配置设置?如果是这样,我希望看到代码示例(C#).

我已经看过关于这个问题的其他讨论,但我仍然不清楚.

c# xml configuration-files application-settings winforms

561
推荐指数
11
解决办法
43万
查看次数

从其他应用打开"设置"应用

好吧,我知道有很多问题,但它们都来自很久以前.

所以.我知道这是可能的,因为地图应用程序可以做到这一点.

在地图应用程序中,如果我关闭此应用程序的本地化,它会向我发送一条消息,如果我按好,"设置应用程序"将打开.我的问题是,这怎么可能?如何从我自己的应用程序中打开"设置应用程序"?

基本上我需要做同样的事情,如果用户关闭我的应用程序的位置,那么我会给他一条消息,说明会打开"设置应用程序"

iphone objective-c appsettings application-settings ios

166
推荐指数
9
解决办法
16万
查看次数

如何修复错误:"无法通过创建架构找到属性/元素的架构信息"

我有一个使用C#在VS2010中编写的Windows窗体应用程序,并在app.config文件中获得以下错误:

Message 4   Could not find schema information for the attribute 'name'
Message 8   Could not find schema information for the attribute 'name'
Message 12  Could not find schema information for the attribute 'name'
Message 5   Could not find schema information for the attribute 'serializeAs'
Message 15  Could not find schema information for the element 'CCP_Utility.Settings1'
Message 2   Could not find schema information for the element 'CCP_Utility.Properties.Settings'
Message 3   Could not find schema information for the element 'setting' …
Run Code Online (Sandbox Code Playgroud)

c# error-handling application-settings database-schema

147
推荐指数
3
解决办法
20万
查看次数

App.config:用户与应用程序范围

我在我的项目中添加了App.config文件.我从Project> Properties> Settings面板创建了两个设置 -

在此输入图像描述

我注意到当我添加设置时,我可以将范围定义为UserApplication.-

  1. 用户
  2. 应用

如果我定义设置,因为User它转到userSettings部分,
如果我定义设置,因为Application它转到applicationSettings部分

App.config中

<configuration>

    <userSettings>
        <DemoApp.Properties.Settings>
            <setting name="MySetting1" serializeAs="String">
                <value>Value1</value>
            </setting>
        </DemoApp.Properties.Settings>
    </userSettings>

    <applicationSettings>
        <DemoApp.Properties.Settings>
            <setting name="MySetting2" serializeAs="String">
                <value>Value2</value>
            </setting>
        </DemoApp.Properties.Settings>
    </applicationSettings>

</configuration>
Run Code Online (Sandbox Code Playgroud)

但是,这些设置可以通过相同的方式访问.cs-

string mySetting1 = DemoApp.Properties.Settings.Default.MySetting1;
string mySetting2 = DemoApp.Properties.Settings.Default.MySetting2;
Run Code Online (Sandbox Code Playgroud)

在这两者之间应该选择的范围UserApplication范围之间有什么区别?

.net c# app-config application-settings winforms

84
推荐指数
2
解决办法
4万
查看次数

如何在应用程序的设置包中显示应用程序版本修订?

我想在我的应用程序的设置包中包含应用程序版本和内部修订,例如1.0.1(r1243).

Root.plist文件包含这样的片段......

     <dict>
        <key>Type</key>
        <string>PSTitleValueSpecifier</string>
        <key>Title</key>
        <string>Version</string>
        <key>Key</key>
        <string>version_preference</string>
        <key>DefaultValue</key>
        <string>VersionValue</string>
        <key>Values</key>
        <array>
            <string>VersionValue</string>
        </array>
        <key>Titles</key>
        <array>
            <string>VersionValue</string>
        </array>
    </dict>
Run Code Online (Sandbox Code Playgroud)

我想在构建时替换"VersionValue"字符串.

我有一个脚本可以从我的存储库中提取版本号,我需要的是一种在构建时处理(预处理)Root.plist文件的方法,并替换版本号而不影响源文件.

iphone xcode application-settings settings-bundle

83
推荐指数
8
解决办法
5万
查看次数

哪些设计模式可以应用于配置设置问题?

在大型复杂的软件产品中,管理可配置设置成为一个主要的痛苦.我见过这个问题的两种方法是:

  • 让系统中的每个组件从配置文件或注册表设置加载自己的配置.
  • 有一个设置加载器类,它加载所有可配置的系统设置,让每个组件查询设置加载器的设置.

这些方法对我来说都是错的.

是否有可用于简化问题的设计模式?也许会利用依赖注入技术的东西.

configuration design-patterns configuration-files application-settings

71
推荐指数
3
解决办法
3万
查看次数

从iPhone设备查找当前国家/地区

我必须在iPhone设置中获取当前国家/地区.谁能告诉我如何在iPhone应用程序中获取当前国家/地区.

我必须使用当前国家来解析我需要通过当前国家/地区的RSS源.

请帮我找到这个国家.

提前致谢.

iphone objective-c appsettings application-settings ios

50
推荐指数
7
解决办法
5万
查看次数

Azure连接字符串最佳实践

我有一个应用程序,我只是迁移到Azure.目前我使用web.config转换来管理更改数据库连接字符串dev/staging/prod环境.如何在Azure中管理这些多个连接字符串?

connection-string azure application-settings staging azure-sql-database

50
推荐指数
5
解决办法
1万
查看次数

可以使用属性启用/禁用弹簧启动@RestController吗?

给出一个"标准"弹簧启动应用程序@RestController,例如

@RestController
@RequestMapping(value = "foo", produces = "application/json;charset=UTF-8")
public class MyController {
    @RequestMapping(value = "bar")
    public ResponseEntity<String> bar(
        return new ResponseEntity<>("Hello world", HttpStatus.OK);
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有阻止端点开始的注释或技术可言,如果/除非某个应用程序属性存在/不存在.

注意:测试方法内的属性并且爆炸不是解决方案,因为端点将存在.

我不关心粒度:即只启用/禁用方法或整个类都很好.


由于配置文件不是属性,因此通过配置文件进行控制并不能解决我的问题.

java spring application-settings spring-boot

47
推荐指数
1
解决办法
2万
查看次数

访问另一个项目的设置文件

有没有办法从不同的项目访问设置文件?例如,我有一个包含2个项目的解决方案(让我们称之为Proj1和Proj2).我想从Proj1中的Program.cs访问Proj2的应用程序设置.这可能吗?

c# visual-studio-2005 application-settings

42
推荐指数
3
解决办法
4万
查看次数