如何找出其中的.NET Framework版本的可执行文件需要运行? [英] How to find out which version of the .NET Framework an executable needs to run?

查看:439
本文介绍了如何找出其中的.NET Framework版本的可执行文件需要运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可执行文件,我想知道的.NET框架此文件需要启动哪个版本。

I've got an executable file, and I would like to know which versions of the .NET framework this file needs to be started.

有没有一种简单的方法来的地方找到这些信息?

Is there an easy way to find this information somewhere?

(到目前为止,我试过 ILDASM 和的 DUMPBIN 没有任何的运气。)

(So far I tried ILDASM and DUMPBIN without any luck.)

推荐答案

我认为最接近你可以可靠地获得是要确定什么版本的 CLR 是必需的。您可以使用ILDASM并查看清单节点或反射器和查看Application.exe节点作为IL的dissasembly认为做到这一点。在这两种情况下,有一个注释指示CLR版本。在ILDASM,注释//元数据的版本,并在反射的评论是目标运行时版本。

I think the closest you can reliably get is to determine what version of the CLR is required. You can do this by using ILDASM and looking at the "MANIFEST" node or Reflector and looking at the dissasembly view of the "Application.exe" node as IL. In both cases there is a comment that indicates the CLR version. In ILDASM, the comment is "// Metadata version" and in Reflector the comment is "Target Runtime Version".

下面的例子是一个名为WindowsFormsApplication1.exe .NET WinForms应用程序:

Here are examples for a .NET WinForms application named WindowsFormsApplication1.exe:

ILDASM:

// Metadata version: v2.0.50727
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 2:0:0:0
}
.assembly extern System
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 2:0:0:0
}

反射器:

.module WindowsFormsApplication1.exe
.subsystem 0x0002
// MVID: {CA3D2090-16C5-4899-953E-4736D6BC0FA8}
// Target Runtime Version: v2.0.50727

您也可以看看引用的程序集的列表,查找具有最高版本号的参考。

You can also look at the list of referenced assemblies and look for the reference with the highest version number.

再次使用ILDASM在看清单节点数据:

Again, using ILDASM looking at the "MANIFEST" node data:

.assembly extern System.Drawing
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 2:0:0:0
}
.assembly extern System.Core
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 3:5:0:0
}

和使用反射,看着dissambly(依然如IL)列出的每个参考:

And using Reflector, looking at the dissambly (still as IL) for each reference listed:

.assembly extern System.Core
{
    .ver 3:5:0:0
    .publickeytoken = (B7 7A 5C 56 19 34 E0 89)
}

通过找到具有最高版本的元数据的参考,您可以确定哪个版本的参考从何而来,这将表明你需要安装的应用程序运行的框架相同版本的框架。话虽这么说,我不会把它当作100%可靠的,但我不认为它会很快改变。​​

By finding the reference with the highest version metadata you can determine what version of the Framework that reference came from, which would indicate that you need the same version of the Framework installed for the application to run. That being said, I wouldn't treat this as 100% reliable, but I don't think it will change any time soon.

这篇关于如何找出其中的.NET Framework版本的可执行文件需要运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆