My app uses .net 3.5, and compiles successfully under 4.5 without any modifications, so apparently the libraries my app uses exists both in 3.5 & 4.5. But windows 8 explicitly requires 3.5 even though 4.5 is available.
How can I (programatically) make my app use 3.5 when running on windows7 and 4.5 when running on windows8?
PS: Ideally I want to avoid using an app.config file
The only thing I could think to do, is to compile for both frameworks. And include both in your installer package, using it to install the correct one based on what you find on the system.
For App developers (and IT Administrators): IT administrators can configure .NET 3.5 apps to run on either .NET 3.5 or .NET 4.5 (depending on what's already installed). In order to run a managed app on either 3.5 or 4.5, just add a section in the application configuration file. This will ensure that if .NET 3.5 is installed, the app will run on .NET 3.5; otherwise the app will run on .NET 4.5. An example of the additional section in the configuration file is provided below:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
I didn't find a solution which didn't have a dependency on an additional file. But the simplest way I could get my .net 3.5 app to work on windows 8 was creating an app.config file(which I wanted to avoid) and adding the "<supportedRuntime>
" element.
<configuration>
<startup>
<supportedRuntime version="v4.0" />
</startup>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With