views:

181

answers:

2

.NET 4.0 is meant to run side-by-side with 3.5 and won't run 3.5 apps, which is making me worried about having to instruct my users to download .NET 3.5 instead of just "the latest version".

I've read in a blog that the 4.0 installer will install 3.5 as well if it's not already installed but I can't test it right now, did anyone try this or have an answer from a trusted source?

+5  A: 

No, the .NET 4.0 installer will only install version 4. It will run apps targeted to CLR version 2 (like 3.5 apps) if there is no other version of the framework installed. Of course, you ought to test this scenario to make sure the version 4 changes don't have unexpected side effects. Do so by creating or editing the .exe.config file for your app:

<configuration>
  <startup>
    <supportedRuntime version="v4.0.30319"/>
  </startup>
</configuration>

Note that you can't use the VS2008 debugger when you do this.

Hans Passant
Edited out the comment because the code got messed up, see my answer below.
John Doe
+1  A: 

I was able to test it in a .NET 4.0 only box and it wouldn't run out-of-the-box (could not find runtime version error) but your answer made me search about those config files and I found a way to make it run on 3.5 when available but fall back to 4.0. This is the code, if anyone else is having the same issue:

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="false">
        <supportedRuntime version="v2.0.50727" />
        <supportedRuntime version="v4.0" />
    </startup>
</configuration>
John Doe