How can I force my C# application to run using the .net 4.5 runtimes? Even if I have 4.5, 4.6, 4.7, 4.8, etc also installed?
The reason I'm trying to do this is because I wanted to reproduce a bug that existed in an earlier version of WPF, so I wanted to run the code against an earlier version of .Net without having to uninstall anything.
I tried the following:
- Target framework .Net 4.5 in the Application build settings
and then added the following config :
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
To test if it was running the 4.5 runtime, I tried to access something added after 4.5 :
private static bool Is462Installed()
{
// API changes in 4.6.2: https://github.com/Microsoft/dotnet/blob/master/releases/net462/dotnet462-api-changes.md
return Type.GetType("System.Security.Cryptography.AesCng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false) != null;
}
But it returned true. So it is not using a .Net 4.5 runtime?
So I am guessing it will always use the latest runtimes that you have installed?