将设置添加到 app.config 或者将设置添加到 *.exe.config 就足够了吗?

Add a setting to app.config or will adding the setting to *.exe.config be suffice?

最近一篇文章: https://blogs.msdn.microsoft.com/dotnet/2017/04/05/announcing-the-net-framework-4-7/ 宣布可能修复触摸屏支持的间歇性问题。当我阅读文档时,只需更改 app.config 文件即可。查看行:

“您可以使用以下 app.config 条目选择加入新的触控实施。

    <runtime>
            <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.EnablePointerSupport=true"/>

</runtime>

下节:

WPF Touch/Stylus 支持 Windows 10

我的问题是:我可以只在 Myapp.exe.config 中进行更改还是必须在 app.config 中实际进行更改?也许问题可能是:app.config 信息是在编译时使用还是只是翻译成 myapp.exe.config?

此外,我想知道是否可以离开:

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>

文档只提到添加 EnablePointerSupport 而没有提到更改配置文件中的版本。我确实下载了 .NET Framework 4.7 并安装,但没有更改配置文件中的版本。我需要吗?

谢谢。

Can I just make the change in Myapp.exe.config or must I actually make it in app.config?

如果您的 EXE 已部署,您可以更改 App.Exe.Config,重新启动应用程序,将使用新的配置设置。如果您为 ASP.Net 应用程序执行此操作(即更改 web.config),它将导致 IIS 中的应用程序池被回收并使用新的 web.config 设置。

显然添加任何更改到实际 App.Config 所以下次编译时它会自动添加到输出 App.Exe.Config.

你会有更多关于这个的问题,所有这些都记录在这里,请仔细阅读它:

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-configure-an-app-to-support-net-framework-4-or-4-5


The documentation just mentions adding EnablePointerSupport and makes no mention of changing the Version in the config file. I did in fact download the .NET Framework 4.7 and install, but have not changed the Version in the config file. Do I need to?

除非您使用的是 .Net 4.7 特定功能,否则您可以将版本保留为 .Net 4.5。

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>

在这种情况下,文章特别说明了它在 .Net 4.7 中的错误修复。所以你需要使用 4.7。

要更改此设置,您可以编辑项目的构建选项卡属性(或在配置文件中手动编辑)。

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>

这里是对 .Net Frameworks 与 SKU 的参考: https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/supportedruntime-element


If app.config is used at compile time for anything other than producing the Myapp.exe.config file.

  • 你说得对,它在编译时用于生成 App.Exe.Config。

  • 许多人将配置设置存储在配置文件中,因此 App.Exe.Config 也可以在 运行 时编辑。 归根结底,它只是一个 XML 文件。

  • 另请注意,您可以在设计时针对不同的环境对 App.Config 进行转换: