How to get the .Net framework version that the application is using
<p>I have referred the following question <a href="http://stackoverflow.com/questions/951856/is-there-an-easy-way-to-check-net-framework-version-using-c">Is there an easy way to check .NET Framework version using C#?</a> . But the suggestions given there did not work for following purpose.</p>

<p>How can we identify the .Net version that the C# console application is utilizing?</p>

<p><strong>Environment:</strong></p>

<ul>
<li>Visual Studio 2010 </li>
<li>.Net Framework : 3.5 (Please see attached screenshot)</li>
</ul>

<p><strong>CODE</strong></p>

<pre><code>using System;
using System.Globalization;
using Microsoft.Win32;
namespace TESTConsoleApplication
{
class Program
{
    static void Main(string[] args)
    {
        //.Net version: Apporach 1
        RegistryKey installed_versions = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
        string[] version_names = installed_versions.GetSubKeyNames();
        double latestFramework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);
        int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));
        Console.WriteLine(latestFramework);

        //Approach 2
        string versionval = Environment.Version.ToString();
        Console.WriteLine(versionval);

        //Approach 3
        string systemVersionVal = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().ToString();
        Console.WriteLine(systemVersionVal);

        Console.ReadLine();
    }
}

}
</code></pre>

<p><strong>Output</strong></p>

<p><img src="http://i.stack.imgur.com/wwUpj.jpg" alt="enter image description here"></p>

<p><strong>VERSION Setup</strong></p>

<p><img src="http://i.stack.imgur.com/fq75l.jpg" alt="enter image description here"></p>
