11

I have a .NET 2.0 application and I plan to make a 'smart installer' which checks for the available .NET version on the user's PC and install my specific port for it. I saw that:

  • Windows XP (SP2) comes with .NET 2.0
  • Windows Vista comes with .NET 3.0
  • Windows 7 comes with .NET 3.5
  • Windows 8 comes with .NET 4.5

As far as I know, the only thing that's not backward compatible is the CLR version, which is changed after .NET 4.0.

So if I don't want the user to install additional framework just for my application, I should have these versions of my app:

  • .NET 2.0 - XP (SP2 and upper), Vista (3.0 should be able to run 2.0) and 7 (3.5 should be able to run 2.0)
  • .NET 4.0 - if someone installed 4.0 ONLY and have no other
  • .NET 4.5 - for the users that have Windows 8 with no other .NET installed

Am I right? Or 4.5/4.0 are backward compatible?

EDIT: If any of the upper data isn't right, please correct me

blez
  • 4,939
  • 5
  • 50
  • 82
  • 2
    Urgh. You are going to create a different version of your application for each and every version of .NET that is available? Seems like a lot of wasted time and coding effort. Why not just pick the lowest common denominator? – KingCronus Dec 17 '12 at 13:59
  • I won't change a single line, just recompile for 3 different versions. My web installer will pick which one to install. – blez Dec 17 '12 at 13:59
  • 2
    So you won't be using any .NET 3/3.5/4+ features at all. You might as well just have a single .NET 2 version in my opinion? What is your reasoning for not wanting the user to have to install a framework? It seems perfectly reasonable in my opinion. – KingCronus Dec 17 '12 at 14:03
  • I personally don't like forcing users to install frameworks just for a single app. That's one of the reasons I don't like Java and I like .NET. That's why I will make my software not requiring additional installs. – blez Dec 17 '12 at 14:17

2 Answers2

11

As far as I know, the only thing that's not backward compatible is the CLR version, which is changed after .NET 4.0.

This isnt true. You can make your .NET2 compiled application run on the .NET4 framework.

You just need to add the following to your app.config:

<configuration>
<startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Note, I agree with @KingKronus, ie Why not just pick the lowest common denominator?

In your case that would be .NET2 compiled and only one set of pdbs and one compilation set.

Yes, you would need to test your .NET2-compiled app runs OK on the .net4 runtime BUT you would need to test your app in each of the frameworks in your original solution anyway.

wal
  • 17,409
  • 8
  • 74
  • 109
  • Is there the same thing, but for 4.5? And does that work for 3.5 on 4.0 projects too? – blez Dec 17 '12 at 14:10
  • 1
    i was checking that right now...best thing is to try it. see also this link: http://msdn.microsoft.com/en-us/library/ff602939.aspx `The .NET Framework 4.5 is backward-compatible with applications that were built with the .NET Framework versions 1.1, 2.0, 3.0, 3.5, and 4.` – wal Dec 17 '12 at 14:11
  • and yes, that will work on 3.5 projects too; remember that it 'works' because .net3.5 projects still use the .net2 *runtime* – wal Dec 17 '12 at 14:18
  • That's very nice move from Microsoft. But I wonder, what is this post about? http://stackoverflow.com/questions/12612166/how-to-force-net-3-5-application-run-on-net-4-5-runtime – blez Dec 17 '12 at 14:23
  • what about it? thats the same as what i suggested. – wal Dec 17 '12 at 14:29
  • I thought that 4.5 runs all of them without special config. – blez Dec 17 '12 at 14:30
  • no, definitely not. that first link i posted confirms this. the .NET architecture forces you to add the different runtimes to your app.config which makes you at least think about testing them on those different runtimes. adding the config isnt that special, its very quick (and it works too!) – wal Dec 17 '12 at 14:32
  • This solution doesn't seem to work as desired in windows 8.1 because it pops up a dialog saying it *might* not work and recommends installing .net 3.5 even though I copied the above into app.config. – gr5 Feb 28 '15 at 00:01
0
  1. Actually you don't need to check it manually. Your application will show proper message after you run it and ask user to download and install the needed version.

  2. If you still need to support windows XP, choose .NET 4.0. .NET 4.5 will handle it

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
VladL
  • 12,769
  • 10
  • 63
  • 83
  • "Actually you don't need to check it manually. Your application will show proper message after you run it and ask user to download and install the needed version." that's true only on Windows 8. – blez Dec 17 '12 at 14:02
  • 1
    @blez Wrong. Windows XP and Windows 7 will show you that dialog as well, I checked it. Windows XP will not recognize 4.5, but 4.0 for sure – VladL Dec 17 '12 at 14:03
  • I don't want to make the user install the whole framework just for my application. – blez Dec 17 '12 at 14:03
  • Just in case this user doesn't have any .NET frameworks installed, the best choice is to use .NET 4.0 . But I can't imagine any user today, who didn't need .NET 4.0 before your software ;). And I think .NET 4.0 is installed automatically if windows update is ON. – VladL Dec 17 '12 at 14:09
  • Imagine most of the people in China/India who still use XP :) – blez Dec 17 '12 at 14:12
  • @blez Not only China/India, but many other countries, but why did you mentioned that? – VladL Dec 17 '12 at 14:22
  • 1
    @blez, thanks for this great question. Not only are there "developing economies" in Asia, but the US as well. Your thinking is exactly right about meeting customers on their hardware terms. I sell software to medical practices and it's remarkable how many workstations need .NET 2.0-level compatibility. – bwperrin Mar 27 '13 at 16:03