MSDN.WhiteKnight - Stack Overflow answers
Ответ на "When and why do I need the supportedRuntime element and sku attribute?"
Answer 55508625
It's needed to declare which framework versions your application is actually compatible with. Suppose, we have an application that targets .NET Framework 4.7.2 and try to run it on the machine that have only .NET Framework 4.5 installed. If we add this app.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
Windows will show a nice error message that asks to install needed framework version:
If we omit the app.config, Windows will try to run it and then application will crash first time it hits a feature specific to .NET Framework 4.7.2 and absent in installed framework version.
Note that documentation is misleading in saying that "This element should be used by all applications built with version 1.1 or later of the .NET Framework". It might be interpreted as "This element is required for application to run on .NET 1.1+", while in reality it only means that .NET 1.1 changed a syntax from previosly used in .NET 1.0
requiredRuntime
syntax. More often then notsupportedRuntime
is NOT required for application to run, it's just for prettiness.One common scenario when
supportedRuntime
is really needed for application to run is when we have application targeting .NET 2.x-3.x and try to run it on machine that have only 4.x (for example, Windows 10 have 4.6+ but does not have .NET 2.x-3.x installed by default). In this case, withoutsupportedRuntime
in app.config the application won't run at all, even though 4.x is mostly compatible with previous versions. Adding<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
will fix the issue.
So, to sum up, it does not duplicate the information in assembly metadata, but rather give Windows additional information on how to connect application with framework version it is compatible with, and what version to ask user to install if it's not present on target machine.
Content is retrieved from StackExchange API.
Auto-generated by ruso-archive tools.