的app.config< supportedRuntime>config、app、LT、GT

2023-09-02 02:02:56 作者:就在乎你i

假设我有一个WinForms应用程序,是建立和编译的.NET 2.0使用VS2008。

Suppose I have a WinForms app that is built and compiled against .NET 2.0 using VS2008.

这是我的理解是在运行时,应用程序会首先尝试加载.NET 2.0 CLR,(因为这是它被编译的), 无论的对任何可能列在app.config文件中的任何supportedRuntime元素。

It is my understanding that at runtime, the app will attempt to load the .NET 2.0 CLR first, (because that is what it was compiled against), regardless of anything that may be listed in any "supportedRuntime" element of the app.config file.

如果它不能找到它,那么它将会进入通过检查的app.config等决定另一个版本的过程。

If it can't find it, then it will then go through a process of deciding on another version by checking the app.config, etc.

例如,如果.NET 2/3 / 3.5和.NET 4.0都安装一台机器上,我有:

For example, if .NET 2/3/3.5 and .NET 4.0 are installed on a machine, and I have:

<supportedRuntime>V4.0</supportedRuntime>

在App.config,应用程序仍然会选择加载和运行.NET 2.0。

in the app.config, the app will still choose to load and run .NET 2.0.

这是否正确?

感谢。

推荐答案

在MSDN页似乎是清楚的是用于构建一个只有后备情况:

The MSDN page seems to be clear that the one used to build is only the fallback case:

http://msdn.microsoft.com/en-us/library/w4atty68.aspx

如果在&lt; supportedRuntime&GT;元素不是present应用程序配置文件中,用于构建应用程序的运行的版本使用。

If the <supportedRuntime> element is not present in the application configuration file, the version of the runtime used to build the application is used.

您看到的行为不符合这个MSDN页面吗?

Are you seeing behavior that doesn't match that of this MSDN page?