8

I used VS2010, and target for .Net 2.0 (VB.Net Windows Form application)

How to decide what is the .Net target I decided on 2.0 because I understood it will be OK if the users have higher version

I tested my app on XP with .Net 2.0, works fine.

I uninstalled .Net 2.0 [to see what error message users might get]

[a few files were still left in C:\Windows\Microsoft.Net\Framework\v2.0.50727 but not all files]

I installed .Net 4 [. . . also needed to install Windows Installer 3.1, and Windows Imaging Component, as pre-requirments . . .]

but now when I run my app I get the error - "unable to find a version of the runtime to run this application"

so what should I recomend my clients? to install 2.0?

Thanks,

Atara

Update: I am going to recommend my XP users to install .Net 3.5 SP1

Community
  • 1
  • 1
Atara
  • 3,523
  • 6
  • 37
  • 56
  • 1
    It's simple to set it up so it runs on either. Add a .config file and use the `` element twice. For "v2.0" and "v4.0". It will work fine, I'm sure. – Hans Passant Sep 01 '10 at 17:56
  • @Hans: Consider undeleting your answer at http://stackoverflow.com/questions/3619490/why-should-dispose-be-non-virtual/3619621#3619621. It is a good answer, has high upvotes, and is of value to the community, IMO. The downvoter clearly didn't understand the conversation. – Robert Harvey Sep 01 '10 at 17:57
  • @Robert: too many downvotes, I'll save it for a better question. Want to ask it? – Hans Passant Sep 01 '10 at 18:14
  • @Hans: Asked here: http://stackoverflow.com/questions/3621410/why-are-c-interface-methods-not-declared-abstract-or-virtual – Robert Harvey Sep 01 '10 at 19:21

6 Answers6

7

A .NET 2.0 application needs .NET 2.0 to run. A .NET 3.0 or 3.5 application only needs .NET 2.0 plus whatever additional .NEt 3.0/3.5 assemblies it actually uses.

A .NET 4.0 application needs the .NET 4.0 CLR, so .NET 4.0 must be installed.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • my NET 2.0 application run well on Windows 7 and on Vista, so what version of .Net should I tell my XP users to install? – Atara Sep 01 '10 at 17:22
  • @Atara: Vista includes 3.0 and Win7 even 3.5. You can ask to install 2.0 or, as said in another anwser, 3.5 SP1. – wRAR Sep 01 '10 at 17:29
3

You have two choices:

  • Recommend your clients install .NET 3.5 SP1 (nobody installs .NET 2.0 anymore)
  • Target .NET 4.0 and ask your clients to install .NET 4.0 (this might not be accepted very well especially if your clients are some large corporations where company policy doesn't allow it)
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • and .NET 3.5 SP1 will work? I tested my app on Vista, and on Windows 7, and had no problems. I didnot think that XP will cause errors . . . – Atara Sep 01 '10 at 17:19
  • 1
    Yes it will work, .NET 3.5 uses CLR 2.0 which is the same as .NET 2.0, so no problems running your application. – Darin Dimitrov Sep 01 '10 at 17:21
1

Here's a brief overview of which framework is required on select windows OSes [which in my opinion are more commonly encountered].

  • XP: 2.0, 3.0, 3.5, 4.0
  • Vista: 3.5, 4.0
  • Win7: 4.0

As you can see, Microsoft has the frameworks that were already released as of when an OS was being released preinstalled.

It is also worth noting that when you install .NET 3.5 sp1, you automatically get 3.0 and 2.0 installed. This is because they all run on the same underlying framework and each version builds on the previous.

.NET 4 is a completely different animal. It runs on a different underlying framework so you don't automatically get the older versions of the .NET framework when you install it.

Hope this helps.

Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108
0

The moment is build the project, try to access its properties and change the "Target Framework". And select the framework that your clients have. This may solve your problem.

kran1um
  • 972
  • 2
  • 20
  • 33
0

Just because you installed .NET 4.0 doesn't mean your application was targeting .NET 4.0.

If you modify your project settings in Visual Studio to build to target .NET 4.0 and you should no longer get the error (but then your clients will need to install the .NET 4.0 Runtime).

Personally, if you want to release something that is going to run on the majority of client machines already out there, I would target .NET 3.5. Most people are going to have the runtime installed already.

If not, it's easy enough to download from Microsoft.

.

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536
0

You should build an installer (a Setup/Deployment project in Visual Studio) that includes the 2.0 redistributable so that when your clients install your software it will install the necessary .net framework for it to run.

Task
  • 3,668
  • 1
  • 21
  • 32