C# Programming > Miscellaneous

Detect .NET Framework Installed


.NET Framework

Programs coded in any of the .Net languages (C#.Net, VB.Net, etc,) all require the .NET Framework to be installed in the client computer in order to be able to run. Microsoft used to allow you to bundle the .Net Framework installation with your projects but discontinued the practice due to the fact that it made it hard to update the installation files.

However we can try to simulate that behavior by first running an application to check whether the .NET Framework is installed, then move from there. Of course this "checking" application should be written in something that is not a .NET language, Visual Basic 6 or C++ are good examples for writing quick easy applications to check for the Framework.

How to Check

So how exactly do we check if the .NET Framework is installed? There are several ways to do it, but a simple and effective method is to check the registry.

Additionally we can check which version of the .Net Framework is installed. The versions currently are 1.0, 1.1, 2.0, 3.0, and 3.5. Depending on our application, we need to check for the appropriate version.

Here are the registry keys to look for:

SOFTWARE\Microsoft\.NETFramework\Policy\v1.0\3705 has to return 3321-3705
SOFTWARE\Microsoft\.NETFramework\Policy\v1.1\4322 has to return 3706-4322
SOFTWARE\Microsoft\.NETFramework\Policy\v2.0\50727 has to return 50727-50727
SOFTWARE\Microsoft\.NETFramework\Policy\v4.0\30319 has to return 30319-30319

Unfortunately as far as versions 3.0 and 3.5 go, there are not as clear registry entries, although checking you could try to apply the same concept.

Alternatively you can have your application check the following folder:


Any of the .NET Frameworks, versions 1.0 to 4.0 store their system files within that folder. It is up to you to verify simply that the folder exists or if you want to go ahead and verify some of the installtion files.

The C# Example

The example project was written in C#.NET for the sake of simplicity. Obviously writing the a program in C# to detect the .NET Framework defeats the whole purpose, but the actual purpose for this application is to have the written code for reference.

Translating the example into a programming language that is not dependant on the .NET Framework should be much easier...

Back to C# Article List