我如何知道安装了哪个版本的。net ?
我正在寻找一些像java -version一样简单的东西,我可以在命令提示符中键入,并告诉我当前安装的版本。
我最好补充一点,Visual Studio可能不会被安装——这通常是我想知道的关于客户端机器的事情。
我如何知道安装了哪个版本的。net ?
我正在寻找一些像java -version一样简单的东西,我可以在命令提示符中键入,并告诉我当前安装的版本。
我最好补充一点,Visual Studio可能不会被安装——这通常是我想知道的关于客户端机器的事情。
当前回答
如果你经常这样做(就像我一样),你可以在桌面上创建一个如下所示的快捷方式:
右键单击桌面,选择新建→快捷方式。 在location字段中,粘贴这个字符串: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的帖子)。 点击下一步。为快捷方式指定一个名称并完成。
(注意:我不确定这是否适用于4.5,但我可以确认它适用于4.6,以及4.5之前的版本。)
其他回答
这个答案只适用于。net Core !
在您选择的终端中输入dotnet——version将打印出所使用的. net Core SDK的版本。
在这里了解更多关于dotnet命令的信息。
只需键入下面任何一个命令,在第一行中显示最新版本。
1. CSC
2. GACUTIL /l ?
3. CLRVER
如果你安装了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?.*
最后一个命令(5)将列出所有已安装的。net版本(除了4.5),最新版本优先。您需要运行第4个命令来查看是否安装了. net 4.5。
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
最后一个命令(8)将给出所有版本,包括。net 4.5。
如果你正在开发一些。net应用(例如web应用),你可以写一行错误代码(比如调用错误的函数名),然后重新加载页面,就会显示。net版本
MSDN详细介绍了如何从注册表中检查它:
To find .NET Framework versions by viewing the registry (.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. In the Registry Editor, open the following subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP The installed versions are listed under the NDP subkey. 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. To find .NET Framework versions by viewing the registry (.NET Framework 4.5 and later) On the Start menu, choose Run. In the Open box, enter regedit.exe. You must have administrative credentials to run regedit.exe. In the Registry Editor, open the following subkey: 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 Check for a DWORD value named Release. The existence of the Release DWORD indicates that the .NET Framework 4.5 or newer has been installed on that computer.
注意:上面快照中被剪切的最后一行在所有其他操作系统版本上为:461310。我尽我最大的努力避免在截屏时信息被剪切,但表格太大了。
对于所安装的框架版本,它取决于您安装的服务包和修复程序。更多细节请查看MSDN页面。建议在%systemroot%\Microsoft中查找。NET\Framework获取版本。
环境。Version将以编程方式为您提供CLR的版本。
请注意,这是CLR的版本,不一定与您安装的框架的最新版本相同(。NET 3.0和3.5都使用CLR的v2版本)。