Let us look at a small sample that illustrated how this configuration entry works.
public static void Main()
Console.WriteLine("This is a sample");
Let us copy this code to RequireRuntime.cs and compile it. Let us now add a configuration file RequiredRuntime.exe.config which has the following entry in it. If you run it on a machine that has V2.0.50727 installed in it the application runs and prints the appropriate string.
Let us modify the configuration file to require a different version that does not exist. Copy the following to the same configuration file. When you execute the application you will get an error stating the following:
“To run this application, you first must install one of the following version of the .NET Framework:
Contact your application publisher for instructions about obtaining the appropriate version of the .NET Framework”
This is a real cool way to ensure that your application runs only againt the version of the .NET Framework you have tested it against. There is also another configuration entry called SupportedRuntime which comes in real handy. I will write about that in my next blog.