app.config

2019-02-18 20:54发布

问题:

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

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.

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.

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

<supportedRuntime>V4.0</supportedRuntime>

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

Is that correct?

Thanks.

回答1:

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

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

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