Are you a software developer and ever got this message when testing your .NET 2.0 WinForms application on Windows 8?
An app on your PC needs the following Windows feature: .NET Framework 3.5 (includes .NET 2.0 and 3.0)
Even though your application would run on .NET 4, too?
Here is my story on why this happended to me and how to solve.
Why this happens
When you run a .NET application, Windows 8 seems to check whether the required .NET Framework is available. If it is not available, the above message is being displayed.
How to solve it
Windows 8 cannot know whether your application, compiled for .NET 2, also runs on .NET 4. It has the following knowledge:
- The .NET Framework you compiled your application for
- The processor bitness you compiled your application for (i.e. „x86“ or „Any CPU“)
If you want Windows 8 to be aware of anything other, you have to tell. To change the .NET Framework version, I created a configuration file with the same name as the application, in the same folder.
E.g. if your application is „my-app.exe“, your configuration file has to be „my-app.exe.config“. I use the following content of the file:
<?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v4.0"/> </startup> </configuration>
I.e. you have to tell the supported runtime.
This is sometimes not enough, though. In my scenario, I had the application compiled as „Any CPU“ and configured for V2.0.50727 and v4.0 but still the above Windows message appeared.
My mistake was that on the test system, I only had a 32 bit V2.0.50727, not 64-bit, although the Windows itself was 64-bit. (I don’t know whether a 64-bit version of the .NET Framework exists at all)
So to solve this, I re-compiled the application to „x86“ and then, everything worked perfectly.
(Please correct me if any of my technical assumptions above are wrong)