App.Config 和 Web.Config 的区别? [英] Differences between App.Config and Web.Config?

查看:49
本文介绍了App.Config 和 Web.Config 的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 wpf 中构建桌面应用程序时,当人们的答案是指web.config"时,您能否阅读问题文档并安全地替换app.config"?

when building a desktop app in wpf can you read documentation of problems and safely subsititute 'app.config' when people's answer's refer to 'web.config'?

如果是这样,您是否需要注意任何明显的 GOTCHAS?

if so are there any glaring GOTCHAS you have to look out for?

tnx

推荐答案

阅读 文档:

Web.config 和 App.config

的选择配置文件名由您的托管环境决定选择服务.如果您使用 IIS 来托管您的服务,请使用一个 Web.config 文件.如果您使用任何其他托管环境,请使用一个 App.config 文件.

The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file.

在 Visual Studio 中,名为 App.config 的文件用于创建最终配置文件.实际用于的最终名称配置取决于程序集名称.例如,一个装配名为Cohowinery.exe"的最终配置文件名为Cohowinery.exe.config".但是,您只需要修改App.config 文件.对该文件所做的更改将自动进行编译时的最终应用配置文件.

In Visual Studio, the file named App.config is used to create the final configuration file. The final name actually used for the configuration depends on the assembly name. For example, an assembly named "Cohowinery.exe" has a final configuration file name of "Cohowinery.exe.config". However, you only need to modify the App.config file. Changes made to that file are automatically made to the final application configuration file at compile time.

在使用 App.config 文件时,配置系统合并了App.config 文件包含 Machine.config 文件的内容,当应用程序启动并应用配置.这种机制允许在 Machine.config 文件中定义机器范围的设置.App.config 文件可用于覆盖Machine.config 文件;您还可以锁定设置Machine.config 文件,以便他们使用.在 Web.config 的情况下,配置系统合并所有目录下的Web.config文件将应用程序目录引导到配置中被应用.

In using an App.config, file the configuration system merges the App.config file with content of the Machine.config file when the application starts and the configuration is applied. This mechanism allows machine-wide settings to be defined in the Machine.config file. The App.config file can be used to override the settings of the Machine.config file; you can also lock in the settings in Machine.config file so that they get used. In the Web.config case, the configuration system merges the Web.config files in all directories leading up to the application directory into the configuration that gets applied.

这篇关于App.Config 和 Web.Config 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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