有没有工具可以找出PC上安装的.NET框架?

时间:2021-12-19 12:47:22

I know the official way is the registry, but this is kinda timeconsuming.

我知道正式的方式是注册表,但这有点浪费时间。

I have to check installed versions on several PC's, none of them have VisualStudio , but all of them (probably) a version of .NET framework.

我必须在几台PC上检查已安装的版本,它们都没有VisualStudio,但它们都(可能)是.NET框架的一个版本。

Since the hot water probably exists already, where can i find it?

由于热水可能已经存在,我在哪里可以找到它?

5 个解决方案

#1


Here's a free lightweight tool that does it quickly - .NET Version detector 2007

这是一个免费的轻量级工具,它可以快速完成 - .NET Version detector 2007

If you want to do it manually, this page shows 4-5 good ways to do it. The MS Support page presents a method as simple as opening up the Framework folder and checking the versions installed (folder names)!

如果您想手动执行此操作,此页面会显示4-5种好方法。 MS Support页面提供了一个方法,就像打开Framework文件夹并检查安装的版本(文件夹名称)一样简单!

However, If you want to do it programmatically, the HttpBrowserCapabilities class offers a GetClrVersions() method that is accessible through the Request.Browser.GetClrVersions() call. Of course, as others have mentioned, you can always query the Navigator.UserAgent property of the Browser too, via Javascript (I think this will show you the .NET versions only in IE):

但是,如果要以编程方式执行此操作,HttpBrowserCapabilities类将提供可通过Request.Browser.GetClrVersions()调用访问的GetClrVersions()方法。当然,正如其他人所提到的,你也可以通过Javascript查询浏览器的Navigator.UserAgent属性(我想这只会在IE中显示.NET版本):

javascript:alert(navigator.userAgent)

#2


  1. try the homepage of smallestdotnet it is using the user agent of your browser in order to check which .net version you have.
  2. 尝试使用您的浏览器的用户代理的smallestdotnet的主页,以检查您拥有的.net版本。

  3. goto \Windows\Microsoft.NET\Framework\ you will see all the versions that you have.
  4. goto \ Windows \ Microsoft.NET \ Framework \您将看到您拥有的所有版本。

#3


I commonly run across this problem when writing PowerShell scripts. I find the best way to do this is to run the following check at each of the following base directories

编写PowerShell脚本时,我经常遇到这个问题。我发现执行此操作的最佳方法是在以下每个基目录中运行以下检查

  • %WINDIR%\Microsoft.Net\Framework
  • %WINDIR%\Microsoft.Net\Framework64

Don't forget about the second directory or you risk your application breaking on 64 bit machines.

不要忘记第二个目录,否则您可能会在64位计算机上破坏应用程序。

For each of those start points, I look for directories match v\d+\\.\d+\\.\d+ and contain the file mscorlib.dll. It is not sufficient to simply look for directory names because it's possible for the name to exist without actually having that version of the framework being installed. For instance if you have a vista machine you will also have v1.0.3705 and v1.1.4322 but neither of those frameworks are actually installed.

对于每个起始点,我查找目录匹配v \ d + \\。\ d + \\。\ d +并包含文件mscorlib.dll。仅仅查找目录名称是不够的,因为名称可能存在而实际上没有安装该版本的框架。例如,如果你有一个vista机器,你也会有v1.0.3705和v1.1.4322,但这些框架都没有实际安装。

#4


here is a code you can put in ASP.net site or winforms

这是一个代码,你可以放在ASP.net网站或winforms


using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
class Program
{
[DllImport("mscoree.dll")]
private static extern int GetCORSystemDirectory(
[MarshalAs(UnmanagedType.LPWStr)]StringBuilder pbuffer,
int cchBuffer, ref int dwlength);

static void Main(string[] args)
{
GetClrInstallationDirectory();
}

private static void GetClrInstallationDirectory()
{
int MAX_PATH = 260;
StringBuilder sb = new StringBuilder(MAX_PATH);
GetCORSystemDirectory(sb, MAX_PATH, ref MAX_PATH);
Console.WriteLine(sb.ToString());
while(Console.Read() != 'q') ;
}

}
} 

#5


Take a look at the javascript from SmallestDotNet. There is also a good article over at the CodeProject.

看一下SmallestDotNet的javascript。 CodeProject上还有一篇很好的文章。

#1


Here's a free lightweight tool that does it quickly - .NET Version detector 2007

这是一个免费的轻量级工具,它可以快速完成 - .NET Version detector 2007

If you want to do it manually, this page shows 4-5 good ways to do it. The MS Support page presents a method as simple as opening up the Framework folder and checking the versions installed (folder names)!

如果您想手动执行此操作,此页面会显示4-5种好方法。 MS Support页面提供了一个方法,就像打开Framework文件夹并检查安装的版本(文件夹名称)一样简单!

However, If you want to do it programmatically, the HttpBrowserCapabilities class offers a GetClrVersions() method that is accessible through the Request.Browser.GetClrVersions() call. Of course, as others have mentioned, you can always query the Navigator.UserAgent property of the Browser too, via Javascript (I think this will show you the .NET versions only in IE):

但是,如果要以编程方式执行此操作,HttpBrowserCapabilities类将提供可通过Request.Browser.GetClrVersions()调用访问的GetClrVersions()方法。当然,正如其他人所提到的,你也可以通过Javascript查询浏览器的Navigator.UserAgent属性(我想这只会在IE中显示.NET版本):

javascript:alert(navigator.userAgent)

#2


  1. try the homepage of smallestdotnet it is using the user agent of your browser in order to check which .net version you have.
  2. 尝试使用您的浏览器的用户代理的smallestdotnet的主页,以检查您拥有的.net版本。

  3. goto \Windows\Microsoft.NET\Framework\ you will see all the versions that you have.
  4. goto \ Windows \ Microsoft.NET \ Framework \您将看到您拥有的所有版本。

#3


I commonly run across this problem when writing PowerShell scripts. I find the best way to do this is to run the following check at each of the following base directories

编写PowerShell脚本时,我经常遇到这个问题。我发现执行此操作的最佳方法是在以下每个基目录中运行以下检查

  • %WINDIR%\Microsoft.Net\Framework
  • %WINDIR%\Microsoft.Net\Framework64

Don't forget about the second directory or you risk your application breaking on 64 bit machines.

不要忘记第二个目录,否则您可能会在64位计算机上破坏应用程序。

For each of those start points, I look for directories match v\d+\\.\d+\\.\d+ and contain the file mscorlib.dll. It is not sufficient to simply look for directory names because it's possible for the name to exist without actually having that version of the framework being installed. For instance if you have a vista machine you will also have v1.0.3705 and v1.1.4322 but neither of those frameworks are actually installed.

对于每个起始点,我查找目录匹配v \ d + \\。\ d + \\。\ d +并包含文件mscorlib.dll。仅仅查找目录名称是不够的,因为名称可能存在而实际上没有安装该版本的框架。例如,如果你有一个vista机器,你也会有v1.0.3705和v1.1.4322,但这些框架都没有实际安装。

#4


here is a code you can put in ASP.net site or winforms

这是一个代码,你可以放在ASP.net网站或winforms


using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
class Program
{
[DllImport("mscoree.dll")]
private static extern int GetCORSystemDirectory(
[MarshalAs(UnmanagedType.LPWStr)]StringBuilder pbuffer,
int cchBuffer, ref int dwlength);

static void Main(string[] args)
{
GetClrInstallationDirectory();
}

private static void GetClrInstallationDirectory()
{
int MAX_PATH = 260;
StringBuilder sb = new StringBuilder(MAX_PATH);
GetCORSystemDirectory(sb, MAX_PATH, ref MAX_PATH);
Console.WriteLine(sb.ToString());
while(Console.Read() != 'q') ;
}

}
} 

#5


Take a look at the javascript from SmallestDotNet. There is also a good article over at the CodeProject.

看一下SmallestDotNet的javascript。 CodeProject上还有一篇很好的文章。