How To Check If The .Net Framework Is Installed [C# / WPF]

12,781

Solution 1

a) You would have to bootstrap the program with a non .NET language (C++, VB6, etc) instead of Form_Load (other posters are correct - if the framework isn't installed, the .NET program won't run). An example is here:

http://www.codeproject.com/KB/mcpp/DotNetTester.aspx

b) You can't put a hyperlink in a MessageBox, so you would have to create your own popup dialog (a form). EDIT: That form / dialog would have to be in the bootstrap program.

Solution 2

You can not do this from your application. The application will fail to start.

One option you can do is make a ClickOnce installation that will verify that .NET is installed.

Solution 3

You can't do it in .NET because that would require .NET in the first place. However, you can create a native application that will perform the check than launch your .NET application. This post explains how to detect the .NET framework version.

Share:
12,781
dinbrca
Author by

dinbrca

I own the following website: www.codecaged.com

Updated on June 04, 2022

Comments

  • dinbrca
    dinbrca almost 2 years

    Before starting my application (on Form Load) I want to check and ensure that the .NET framework (3.5 or higher) are installed on the machine - if not I want to prompt the user to download and install it (simple MessageBox with a INTERNET LINK to the Microsoft WebPage would be the best idea no?) So, this actually entails two questions...

    a) How do I DETERMINE IF .NET FrameWork 3.5 or higher are installed? (I don't trust or want to just look for the C:\Program Files\Microsoft.NET folder, seems error-prone no?) Seeing as this is so very crucial there must be a nice way in C# to determine what version of .NET the user has running on his machine? I just have no clue how..

    b) HOW do I paste an INTERNET LINK (hyperlink?) in a MessageBox? So that if the user does NOT have the .NET framework (1.1 or 2.0) installed I can have them simply click on the link to go download it?

    Any help/hints would be greatly appreciated.

    Thanks, Din