4

I am writing a WPF C# Desktop app, and I want to check if the client computer has .NET installed before running the application.

How to check what version of .NET has been installed on the client computer? Or, is it possible?

KMC
  • 19,548
  • 58
  • 164
  • 253
  • possible duplicate of [How to safely check .net framework version using a .net framework version that may not exist?](http://stackoverflow.com/questions/643201/how-to-safely-check-net-framework-version-using-a-net-framework-version-that-ma) – Hans Passant Jul 07 '11 at 14:30
  • 1
    possible duplicate of [How to detect what .NET Framework versions and service packs are installed?](http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed) – Magnus Jul 07 '11 at 14:31

5 Answers5

5

Checking if the right .NET version is installed is not the job of your application, because if it isn't installed, your application won't start in the first place.

You should create an installer that does the checking. The setup project you can create in Visual Studio does this by default.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hinek
  • 9,519
  • 12
  • 52
  • 74
2

There seem to be a couple of methods:

Justin
  • 84,773
  • 49
  • 224
  • 367
0

You can check it in the setup installer. A WPF application can't run on a computer without .NET.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
VoimiX
  • 1,180
  • 3
  • 16
  • 31
0

Your .NET app won't run without the right Framework installed and they'll get an error. You can include .NET Framework redistributable as part of your installation to ensure user has Framework installed when they run your app.

Cortright
  • 1,164
  • 6
  • 19
0

ClickOnce has some features to help with this.

When you publish your application, it'll allow you to specify what dependencies you have, including the .NET framework. If the dependencies are missing, the ClickOnce setup will install them before running the application.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NathanAW
  • 3,329
  • 18
  • 19