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
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.
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.
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.
Your code will not run without the framework so you will not be able to show the dialog box.
This check should be done on install.
So you want to make a .NET application that checks if .NET is installed on the machine?
If .NET Framework is not installed, how do you suppose that program manages to start up in the first place?
This question makes no sense.
The author wants to be able to detect if the .NET Framework 3.5 installed but offer a link to .NET Framework 1.1 and/or .NET Framework 2.0. Besides the fact you could easily just build a setup project that does exactly this just like Paint.net does ( although they do have a bootstrapper ) you would want to make sure the correct version of the .NET Framework is installed.
If the only thing that is installed is .NET Framework 1.1 and you didn't install the .NET Framework 4.0/3.5 for your user you would have a serious problem.
If your pushing .NET Framework 4.0 then your not helping your fellow programmers.
精彩评论