.Net: How do I find the .NET version?

后端 未结 19 2380
我寻月下人不归
我寻月下人不归 2020-11-28 00:49

How do I find out which version of .NET is installed?

I\'m looking for something as simple as \"java -version\" that I can type at the command prompt and that tells

相关标签:
19条回答
  • 2020-11-28 01:06

    Before going to a command prompt, please follow these steps...

    Open My Computer → double click "C:" drive → double click "Windows" → double click "Microsoft.NET" → double click "Framework" → Inside this folder, there will be folder(s) like "v1.0.3705" and/or "v2.0.50727" and/or "v3.5" and/or "v4.0.30319".

    Your latest .NET version would be in the highest v number folder, so if v4.0.30319 is available that would hold your latest .NET framework. However, the v4.0.30319 does not mean that you have the .NET framework version 4.0. The v4.0.30319 is your Visual C# compiler version, therefore, in order to find the .NET framework version do the following.

    Go to a command prompt and follow this path:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319 (or whatever the highest v number folder)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319 > csc.exe

    Output:

    Microsoft (R) Visual C# Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 Copyright (C) Microsoft Corporation. All rights reserved.

    Example below:

    Enter image description here

    0 讨论(0)
  • 2020-11-28 01:09

    Here is the Power Shell script which I used by taking the reference of:

    https://stackoverflow.com/a/3495491/148657

    $Lookup = @{
        378389 = [version]'4.5'
        378675 = [version]'4.5.1'
        378758 = [version]'4.5.1'
        379893 = [version]'4.5.2'
        393295 = [version]'4.6'
        393297 = [version]'4.6'
        394254 = [version]'4.6.1'
        394271 = [version]'4.6.1'
        394802 = [version]'4.6.2'
        394806 = [version]'4.6.2'
        460798 = [version]'4.7'
        460805 = [version]'4.7'
        461308 = [version]'4.7.1'
        461310 = [version]'4.7.1'
        461808 = [version]'4.7.2'
        461814 = [version]'4.7.2'
        528040 = [version]'4.8'
        528049 = [version]'4.8'
    }
    
    # For One True framework (latest .NET 4x), change the Where-Oject match 
    # to PSChildName -eq "Full":
    Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
      Get-ItemProperty -name Version, Release -EA 0 |
      Where-Object { $_.PSChildName -match '^(?!S)\p{L}'} |
      Select-Object @{name = ".NET Framework"; expression = {$_.PSChildName}}, 
    @{name = "Product"; expression = {$Lookup[$_.Release]}}, 
    Version, Release
    

    The above script makes use of the registry and gives us the Windows update number along with .Net Framework installed on a machine.

    Reference: https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#to-find-net-framework-versions-by-querying-the-registry-in-code-net-framework-45-and-later

    Here are the results for the same when running that script on two different machines

    1. Where .NET 4.7.2 was already installed:

    1. Where .NET 4.7.2 was not installed:

    0 讨论(0)
  • 2020-11-28 01:09

    Try .NET Checker by Scott Hanselman.

    0 讨论(0)
  • 2020-11-28 01:10

    There is an easier way to get the exact version .NET version installed on your machine from a cmd prompt. Just follow the following instructions;

    1. Open the command prompt (i.e Windows + R → type "cmd").
    2. Type the following command, all on one line:

    reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP"

    (This will list all the .NET versions.)

    1. If you want to check the latest .NET 4 version.
    2. Type following instruction, on a single line:

    reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full" /v version

    Please find the attached image below to see how it is shown.

    0 讨论(0)
  • 2020-11-28 01:11

    If you'r developing some .Net app (for ex. web app), you can make 1 line of error code (like invoke wrong function name) and reload your page, the .Net version will be show

    0 讨论(0)
  • 2020-11-28 01:12

    For the version of the framework that is installed, it varies depending on which service packs and hotfixes you have installed. Take a look at this MSDN page for more details. It suggests looking in %systemroot%\Microsoft.NET\Framework to get the version.

    Environment.Version will programmatically give you the version of the CLR.

    Note that this is the version of the CLR, and not necessarily the same as the latest version of the framework you have installed (.NET 3.0 and 3.5 both use v2 of the CLR).

    0 讨论(0)
提交回复
热议问题