.NET 3.5 and 4 compatible exe

Is it possible to create a single file exe application that runs on .NET 3.5 and 4, depending on what is installed?

I know I can make a .NET 3.5 application run on 4.x by providing an additional file .exe.config

:

<configuration>
  <startup>
    <supportedRuntime version="v4.0" /> 
    <supportedRuntime version="v2.0.50727" /> 
  </startup>
</configuration>

      

Can I insert this information into my .exe

file?

Registry changes are not parameters.

Edit: Since there are claims that it "just works", here's a minimal example:

public class Hello
{
    public static void Main()
    {
        System.Console.WriteLine("Hello, world!");
    }
}

      

compiled with:

C:\Windows\Microsoft.NET\Framework\v3.5\csc hello.cs

      

when running on Windows 8 without .NET 3.5, it is suggested to install .NET 3.5. I would like to avoid this invitation and work on any new .NET Framework.

+3


source to share





All Articles