tags:

views:

47

answers:

2

Hi,

I am writing a custom installer in C#.

Can you tell me an easy way to check if the machine has .NET version installed [even 2.0].

In cases where it is not installed, my app doesn't even start.

Thanks

+1  A: 

I don't know what is your custom installer, but you could use a Setup and Deployment Project in Visual Studio where you can define .NET Framework launch condition.

Darin Dimitrov
+2  A: 

MSDN has a blog post with sample code to detect if .NET 3 is installed.

[Edit: As mentioned by Stephen Clearly, the author of the blog post also released a tool that can be easily wrapped in a custom installer (and supports all .NET versions)]

Otherwise:

You could always use the file system and check in the %systemroot%\Microsoft.NET\Framework folder.

This will tell you if the following release versions of .NET are installed

  • v3.5
  • v3.0
  • v2.0.50727
  • v1.1.4322
  • v1.0.3705
Dan McGrath
The writer of that blog post also released a [tool](http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx) that can be easily wrapped in a custom installer (and supports all .NET versions).
Stephen Cleary