[英]How do I find the .NET version?
How do I find out which version of .NET is installed?如何找出安装了哪个版本的 .NET?
I'm looking for something as simple as java -version
that I can type at the command prompt and that tells me the current version(s) installed.我正在寻找像
java -version
这样简单的东西,我可以在命令提示符下键入它并告诉我当前安装的版本。
I better add that Visual Studio may not be installed - this is typically something that I want to know about a client machine.我最好补充一点,可能未安装 Visual Studio——这通常是我想了解的有关客户端计算机的信息。
There is an easier way to get the exact version .NET version installed on your machine from a cmd prompt.有一种更简单的方法可以从 cmd 提示符获取安装在计算机上的确切版本 .NET 版本。 Just follow the following instructions;
只需按照以下说明进行操作;
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP"
(This will list all the .NET versions.) (这将列出所有 .NET 版本。)
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.请在下面找到所附图片以查看其显示方式。
Just type any one of the below commands to give you the latest version in the first line.只需键入以下任何一个命令,即可在第一行为您提供最新版本。
1. CSC
2. GACUTIL /l ?
3. CLRVER
You can only run these from the Visual Studio Command prompt if you have Visual Studio installed, or else if you have the .NET framework SDK, then the SDK Command prompt.如果您安装了 Visual Studio,则只能从 Visual Studio 命令提示符运行这些命令,或者如果您有 .NET 框架 SDK,则只能在 SDK 命令提示符下运行。
4. wmic product get description | findstr /C:".NET Framework"
5. dir /b /ad /o-n %systemroot%\Microsoft.NET\Framework\v?.*
The last command (5) will list out all the versions (except 4.5) of .NET installed, latest first .最后一个命令 (5) 将列出所有已安装的 .NET 版本(4.5 除外),最新的优先。
You need to run the 4th command to see if .NET 4.5 is installed.您需要运行第 4 个命令来查看是否安装了 .NET 4.5。
Another three options from the PowerShell command prompt is given below.下面给出了 PowerShell 命令提示符中的另外三个选项。
6. [environment]::Version
7. $PSVersionTable.CLRVersion
8. gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | gp -name Version,Release -EA 0 |
where { $_.PSChildName -match '^(?!S)\p{L}'} | select PSChildName, Version, Release
The last command (8) will give you all versions, including .NET 4.5.最后一个命令 (8) 将为您提供所有版本,包括 .NET 4.5。
Before going to a command prompt, please follow these steps...在进入命令提示符之前,请按照以下步骤操作...
Go to "C:/Windows/Microsoft.NET/Framework" → Inside this folder, there will be folder(s) like (all or any):转到“C:/Windows/Microsoft.NET/Framework”→在此文件夹中,将有文件夹(全部或任何):
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.您最新的 .NET 版本将位于 v 编号最高的文件夹中,因此如果“v4.0.30319”可用,它将包含您最新的 .NET 框架。 However, the "v4.0.30319" does not mean that you have the .NET framework version 4.0.
但是,“v4.0.30319”并不意味着您拥有 .NET 框架 4.0 版。 The "v4.0.30319" is your Visual C# compiler version, therefore, in order to find the .NET framework version do the following.
“v4.0.30319”是您的 Visual C# 编译器版本,因此,为了找到 .NET 框架版本,请执行以下操作。
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 (或任何最高 v 号文件夹)
C:\Windows\Microsoft.NET\Framework\v4.0.30319 > csc.exe
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.
适用于Microsoft (R) .NET Framework 4.5的 Microsoft (R) Visual C# 编译器版本 4.0.30319.17929 版权所有 (C) Microsoft Corporation。 All rights reserved.
版权所有。
Example below:下面的例子:
.NET 版本检测器是一个 GUI 实用程序,它显示安装了框架的六个(!)版本中的哪一个。
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.
查看此 MSDN 页面了解更多详细信息。 It suggests looking in
%systemroot%\Microsoft.NET\Framework
to get the version.它建议查看
%systemroot%\Microsoft.NET\Framework
以获取版本。
Environment.Version will programmatically give you the version of the CLR. Environment.Version将以编程方式为您提供 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).请注意,这是 CLR 的版本,不一定与您安装的框架的最新版本相同(.NET 3.0 和 3.5 都使用 v2 的 CLR)。
MSDN details it here very nicely on how to check it from registry: MSDN 在这里非常详细地详细介绍了如何从注册表中检查它:
To find .NET Framework versions by viewing the registry (.NET Framework 1-4)
通过查看注册表查找 .NET Framework 版本 (.NET Framework 1-4)
- On the Start menu, choose Run.
在开始菜单上,选择运行。
- In the Open box, enter regedit.exe.You must have administrative credentials to run regedit.exe.
在“打开”框中,输入 regedit.exe。您必须具有管理凭据才能运行 regedit.exe。
In the Registry Editor, open the following subkey:
在注册表编辑器中,打开以下子项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
The installed versions are listed under the NDP subkey.
已安装的版本列在 NDP 子项下。 The version number is stored in the Version entry.
版本号存储在版本条目中。 For the .NET Framework 4 the Version entry is under the Client or Full subkey (under NDP), or under both subkeys.
对于 .NET Framework 4,版本条目位于 Client 或 Full 子项下(在 NDP 下),或在两个子项下。
To find .NET Framework versions by viewing the registry (.NET Framework 4.5 and later)
通过查看注册表查找 .NET Framework 版本(.NET Framework 4.5 及更高版本)
- On the Start menu, choose Run.
在开始菜单上,选择运行。
- In the Open box, enter regedit.exe.
在“打开”框中,输入 regedit.exe。 You must have administrative credentials to run regedit.exe.
您必须具有管理凭据才能运行 regedit.exe。
In the Registry Editor, open the following subkey:
在注册表编辑器中,打开以下子项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
Note that the path to the Full subkey includes the subkey Net Framework rather than .NET Framework
请注意,完整子项的路径包括子项 Net Framework 而不是 .NET Framework
Check for a DWORD value named
Release
.检查名为
Release
的 DWORD 值。 The existence of the Release DWORD indicates that the .NET Framework 4.5 or newer has been installed on that computer.Release DWORD 的存在表明该计算机上已安装 .NET Framework 4.5 或更高版本。
Note : The last row in the above snapshot which got clipped reads On all other OS versions: 461310
.注意:上述快照中被剪辑的最后一行读取
On all other OS versions: 461310
。 I tried my level best to avoid the information getting clipped while taking the screenshot but the table was way too big.我尽力避免在截屏时信息被截断,但表格太大了。
Just type the following in the command line:只需在命令行中键入以下内容:
dir /b /ad /o-n %systemroot%\Microsoft.NET\Framework\v?.*
Your dotnet version will be shown as the highest number.您的 dotnet 版本将显示为最高数字。
If you open a command prompt and type the following two commands, all framework versions that are installed on the current machine will be listed (each one is stored in a separate directory within this directory).如果您打开命令提示符并键入以下两个命令,则将列出当前机器上安装的所有框架版本(每个版本都存储在此目录中的单独目录中)。
cd %systemroot%\Microsoft.NET\Framework
dir /A:D
If you do this fairly frequently (as I tend to do) you can create a shortcut on your desktop as follows:如果你经常这样做(我倾向于这样做),你可以在桌面上创建一个快捷方式,如下所示:
powershell.exe -noexit -command "gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | gp -name Version,Release -EA 0 | where { $_.PSChildName -match '^(?!S)\p{L}'} | select PSChildName, Version, Release"
(this is from Binoj Antony's post ).powershell.exe -noexit -command "gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | gp -name Version,Release -EA 0 | where { $_.PSChildName -match '^(?!S)\p{L}'} | select PSChildName, Version, Release"
(来自Binoj Antony 的帖子)。 (NOTE: I am not sure if this works for 4.5, but I can confirm that it does work for 4.6, and versions prior to 4.5.) (注意:我不确定这是否适用于 4.5,但我可以确认它适用于 4.6 和 4.5 之前的版本。)
My god, so much mess to find version of installed .net framework?天哪,找到已安装的 .net 框架的版本这么乱?
Windows > Search > Visual Studio Installer > for installed version of VS, tap on More > Modify > Individual Components and see it there: Windows > 搜索 > Visual Studio Installer > 对于已安装的 VS 版本,点击更多 > 修改 > 单个组件并在那里查看:
To just get the installed version(s) at the command line, I recommend using net-version .要在命令行中获取已安装的版本,我建议使用net-version 。
Source code is available on github.com源代码可在github.com上获得
Full disclosure: I created this tool myself out of frustration.完全披露:出于沮丧,我自己创建了这个工具。
Here is the Power Shell script which I used by taking the reference of:这是我通过参考使用的 Power Shell 脚本:
https://stackoverflow.com/a/3495491/148657 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.上面的脚本利用了注册表,并为我们提供了 Windows 更新号以及安装在机器上的 .Net Framework。
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参考: https ://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#to-find-net-framework-versions-by- 在代码网络框架 45 及更高版本中查询注册表
Here are the results for the same when running that script on two different machines以下是在两台不同机器上运行该脚本时相同的结果
打开 cmd 提示符类型:
dotnet --info
试试 Scott Hanselman 的.NET Checker
。
clrver
is an excellent one. clrver
是一个优秀的。 Just execute it in the .NET prompt and it will list all available framework versions.只需在 .NET 提示符下执行它,它就会列出所有可用的框架版本。
For anyone running Windows 10 1607 and looking for .net 4.7 .对于运行 Windows 10 1607并正在寻找.net 4.7的任何人。 Disregard all of the above.
无视以上所有。
It's not in the Registry , C:\Windows\Microsoft.NET folder or the Installed Programs list or the WMIC display of that same list.它不在Registry 、 C:\Windows\Microsoft.NET文件夹或Installed Programs列表或同一列表的 WMIC 显示中。
Look for "installed updates" KB3186568.查找“已安装的更新”KB3186568。
Per Microsoft in powershell:每个 Microsoft 在 powershell 中:
Get-ChildItem "hklm:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Release | % { $_ -ge 394802 }
See the table at this link to get the DWORD value to search for specific versions:请参阅此链接中的表格以获取 DWORD 值以搜索特定版本:
https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#ps_a https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#ps_a
Open cmd on your pc在你的电脑上打开 cmd
After just text this command;只需发送此命令即可;
"dotnet --version" “dotnet--版本”
Run the following command on CMD:在 CMD 上运行以下命令:
It will display all installed versions of .net, as seen in image above.它将显示 .net 的所有已安装版本,如上图所示。 You can also run the following command below to see the .net version that is in use:
您还可以在下面运行以下命令来查看正在使用的 .net 版本:
There is an easier way to get the exact version .NET version installed on your machine from a cmd prompt.有一种更简单的方法可以从 cmd 提示符获取安装在您的计算机上的确切版本 .NET 版本。 Just follow the following instructions;
只需按照以下说明进行操作;
Open the command prompt (ie Windows + R → type “cmd”) and type the following command, all on one line: %windir%\\Microsoft.NET\\FrameWork, and then navigating to the directory with the latest version number.打开命令提示符(即 Windows + R → 键入“cmd”)并在一行中键入以下命令:%windir%\\Microsoft.NET\\FrameWork,然后导航到具有最新版本号的目录。
Refer to http://dotnettec.com/check-dot-net-framework-version/请参阅http://dotnettec.com/check-dot-net-framework-version/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.