When and why do I need a supported runtime element and sku attribute?

Most (if not all) C # libraries (and F # and VB) and executable projects created in Visual Studio have an automatically added file app.configthat indicates the version of execution and the target frame nickname (TFM):

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

Even without a file app.config, the compiler always generates an assembly-level attribute, as ILDASM shows:

.custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01    // ....NETFramework
                                                                                                      ..    // ,Version=v4.6.1.
                                                                                      bytes snipped-> ..    // .T..FrameworkDis
                                                                                                      ..    // playName..NET Fr
                                                                                                      61  ) // amework 4.6.1

The file .csprojcontains the target frameworks, and I assume that this is the place where the target is passed from the compiler during the build.

, , <startup> . , , , , , . Windows.

, " , .NET 4.0, , , ", , , , .

, TFM .config , , ? .

+4

Source: https://habr.com/ru/post/1689288/


All Articles