Checking .Net frameworks is installed or not on local machine by C#
I have a problem. I make an exe file by C#. Now I want to check local machine is installed .Net frameworks or not? If my local already install it so my program run normal. And if my local not yet install .Net frame so my program have to download any .Net framework to my local. That is all my boss request. (As I know one program by .exe file can not check and download .Net framework file on local machine if it not yet install any .Net framework. If I make my program by setup file so I can control this.). Now I want to have one solution for that. Everyone! Can you help me about my boss request? Thanks!
Ta Long VanPosted Feb 15, 2011, 12:32 AM
ShankeyPosted Feb 15, 2011, 12:09 AM
for checking .net frame work is installed or not:
here are two options, but only second option seems to be better:
- Environment.Version property of .Net framework. For example, this
simple C# source code can be compiled to a .Net console program that
shows .Net framework version installed:
- Limitation of Environment.Version property
– only one of the multiple .Net framework versions installed will be
reported. I.e. if you've .Net 2.0, .Net 3.0 and .Net 3.5 version
installed, Environment.Version reports only .Net 2.0 framework.
Reference : http://www.walkernews.net/2008/05/16/how-to-check-net-framework-version-installed/You don't have to install Visual Studio except the .Net framework SDK (which package all the .Net command line compilers, including the C# compiler). Thus, to compile the C# code in a source file called sample.cs with C# command line compiler, just enter this at Command Prompt:
csc sample.csTo overcome this problem, Aaron Stebner's .Net version checker source code is better choice, where the programming approach is to query the Windows Registry keys and also call the mscoree.dll exported APIs to report the presence of all .NET Framework versions.