Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect what .NET version the application is running on?

Tags:

c#

.net

I tried using Environment.Version.ToString() to determine what .NET framework on the target machine is in use, but it says I'm using .NET 2.0, when version 4.0 is installed.

How do I detect what version of the .NET Framework is running on the target machine?

like image 355
Gilad Naaman Avatar asked Dec 29 '10 17:12

Gilad Naaman


2 Answers

Environment.Version.ToString(); returns version of your application not system, you can read the version from registry or search in %windows%\Microsoft.NET\Framework folders to find maximum number.

The registry key is HKLM\Software\Microsoft\NET Framework Setup\NDP\ see How to detect what .NET Framework versions and service packs are installed?

like image 196
Saeed Amiri Avatar answered Nov 10 '22 03:11

Saeed Amiri


To find out what versions of .NET are available on a machine, you need to look in the registry - see Determine which versions and service pack levels of .NET Framework are installed.
(Originally MSDN KB article 318785)

like image 22
MarkXA Avatar answered Nov 10 '22 01:11

MarkXA