Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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> 

Win8 will detect the need for 3.5 and seamlessly prompt the user to install it. Not really worth jumping through hoops to further streamline

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top