asp.net - App.Config 和 Web.Config 之间的区别?

标签 asp.net wpf web-services app-config

在 wpf 中构建桌面应用程序时,您可以阅读问题文档并在人们的答案引用“web.config”时安全地替换“app.config”吗?

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

tnx

最佳答案

阅读Documentation :

Web.config and 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.

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.

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.

关于asp.net - App.Config 和 Web.Config 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1412552/

相关文章:

java - WS 到服务关注点

asp.net - IIS URL 重写 - 具有多个域

asp.net - 如何从 ASP.NET 应用程序异步调用 Web 服务?

asp.net - 我的ASP.NET项目出现很多错误。为什么?

c# - 什么是 ew :CalendarPopup control in aspx

wpf - 为手持设备开发

android - 从 Android 中的 SOAP 网络服务获取响应

wpf - 从 WPF 中的 ListBox 中删除项目?

c# - 此 XAML 代码中的 IsEmpty 引用/成员在哪里?

java - Spring 返回自定义 SOAP 故障