获取使用每个.NET版本的程序列表安装在我的机器上我的、版本、程序、列表

2023-09-04 06:30:33 作者:我的久伴不及她的一声轻唤

这是不是一个迫切需要但更多的是好奇,我曾在我的脑海里一段时间。对于每一个.NET framework版本,安装在我的机器上,我想列出了需要它的安装的应用程序。有了这个在手,我才能知道我是否可以安全地删除早期版本的框架,而不会造成任何程序失败。是否有这样的工具?我有点怀疑,从而紧随其后我会采取怎样code在C#的建议。

输出示例:

  .NET 1.1所要求的:
    ProgramX,ProgramY,...
.NET 2.0所要求的:
    ProgramA,ProgramB,ProgramC,...
.NET 3.0所要求的:
    ...
.NET 3.5所要求的:
    ...
.NET 4.0中所要求的:
    ...
 

解决方案

只是一些指针什么需要,我怀疑你会追求这个,当你发现了什么需要。

的出发点是写code枚举所有的EXE和DLL文件在磁盘驱动器。为您找到的每个文件,你首先要检查它是否确实是一个托管的程序。接下来,你需要从COR头抬起元数据版本号。它指明了CLR版本的可执行建反对票。共同的价值观是2.0.50727用于.NET 2.0,3.0和3.5,4.0.30319的.NET 4.0,我不知道。NET 1.x中的数字

接下来,您需要使用Assembly.GetReferencedAssemblies()来找出.NET程序集是对的依赖。你需要建立自己的是present在2.0,3.0,3.5和它的服务包组件的索引。这可以让你找到所需要的特定版本。

接下来需要分析任何config文件,可能是present一个EXE和检查< requiredRuntime> &LT ; supportedRuntime> 元素。后者的属性是很微妙的,因为它可以出现一次以上。

SysExporter下载 1.50汉化版 SysExporter工具能够从

有可能是一些事情,我忽略了,比如发行组件和bindingRedirects。使用源$ C ​​$ C的程序Ildasm.exe在SSCLI20得到裂纹读元数据版本号。这场胜利对于这样的工具是小的。随着一兆硬盘今天卖了一百块钱,潜在的节省了这样的一个工具,总值约4美分。

This is not an urgent need but more of a curiosity I have had in the back of my mind for awhile. For each .NET framework version installed on my machine I would like to list the installed apps that require it. With this in hand, I could know whether or not I could safely delete earlier framework versions without causing any programs to fail. Is there such a utility? I somewhat doubt it, so as a close second I will take suggestions for how to code this in C#.

Example output:

.NET 1.1 required by:
    ProgramX, ProgramY, ...
.NET 2.0 required by:
    ProgramA, ProgramB, ProgramC, ...
.NET 3.0 required by:
    ...
.NET 3.5 required by:
    ...
.NET 4.0 required by:
    ...

解决方案

Just some pointers to what's needed, I doubt you'll pursue this when you find out what it takes.

Starting point is writing code that enumerates all of the EXE and DLL files on your disk drives. For each file you find, you first have to check if it is indeed a managed program. Next, you need to lift the metadata version number from the COR header. It indicates what CLR version the executable was built against. Common values are 2.0.50727 for .NET 2.0, 3.0 and 3.5, 4.0.30319 for .NET 4.0, I don't know the numbers for .NET 1.x

Next you need to use Assembly.GetReferencedAssemblies() to find out what .NET assemblies it has a dependency on. You'll need to build your own index of assemblies that are present in 2.0, 3.0, 3.5 and its service packs. This lets you find out what specific version is needed.

Next you need to parse any .config file that might be present for an EXE and check for <requiredRuntime> and <supportedRuntime> elements. The latter attribute is the tricky one since it can appear more than once.

There are probably some things I overlooked, like publisher assemblies and bindingRedirects. Use the source code for ildasm.exe in SSCLI20 to get a crack at reading the metadata version number. The win for such a tool is small. With one terabyte drives selling for a hundred bucks today, the potential savings of such a tool are worth about 4 cents.