确定。net框架版本的dll。

时间:2021-08-22 00:10:39

I have an old dll that was compiled against the .NET framework and deployed. I am not sure which version of the .NET framework it was compiled against. I am wondering how I can determine which version of the .NET framework this dll was compiled against? I cannot trust the source code because I believe it has been upgraded to Visual Studio 2008 and changed to .NET framework version 3.5.

我有一个旧的dll,它是针对。net框架编译的。我不确定它所编译的。net框架的哪个版本。我想知道如何确定这个dll编译的。net框架的哪个版本?我不能信任这个源代码,因为我相信它已经升级到Visual Studio 2008,并更改为。net framework 3.5版本。

9 个解决方案

#1


46  

Load it into Reflector and see what it references?

把它加载到反射器中,看看它的引用是什么?

for example:

例如:

确定。net框架版本的dll。

#2


76  

In PowerShell you can use the following to get the target runtime:

在PowerShell中,您可以使用以下命令获取目标运行时:

$path = "C:\Some.dll"
[Reflection.Assembly]::ReflectionOnlyLoadFrom($path).ImageRuntimeVersion

I adapted this to PowerShell from Ben Griswold's answer.

我根据本·格里斯沃尔德(Ben Griswold)的答案改编了PowerShell。

If you want to know the target framework version specified in Visual Studio, use:

如果您想知道Visual Studio中指定的目标框架版本,请使用:

$path = "C:\Some.dll"
[Reflection.Assembly]::ReflectionOnlyLoadFrom($path).CustomAttributes |
Where-Object {$_.AttributeType.Name -eq "TargetFrameworkAttribute" } | 
Select-Object -ExpandProperty ConstructorArguments | 
Select-Object -ExpandProperty value

You should get something like

你应该得到一些类似的东西。

.NETFramework,Version=v4.5.2

= v4.5.2 .NETFramework,版本

#3


56  

dotPeek is a great (free) tool to show this information.

dotPeek是一个很好的(免费的)工具来显示这些信息。

If you are having a few issues getting hold of Reflector then this is a good alternative.

如果你在获得反射器方面有一些问题,那么这是一个很好的选择。

确定。net框架版本的dll。

#4


41  

You can use ILDASM...

您可以使用ILDASM……

ildasm.exe C:\foo.dll /metadata[=MDHEADER] /text /noil

and check for the 'Metadata section' in the output. It would be something like this:

检查输出中的“元数据”部分。大概是这样的:

Metadata section: 0x424a5342, version: 1.1, extra: 0, version len: 12, version: v4.0.30319

元数据部分:0x424a5342,版本:1.1,额外:0,版本len: 12,版本:v4.0.30319。

The 'version' tag will tell you the .NET Framework version. In the above example it is 4.0.30319

“版本”标签会告诉你。net框架版本。在上面的示例中,它是4.0.30319

#5


13  

You have a few options: To get it programmatically, from managed code, use Assembly.ImageRuntimeVersion:

您有几个选项:要以编程方式从托管代码中获得它,请使用Assembly.ImageRuntimeVersion:

Dim a As Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom("C:\path\assembly.dll")
Dim s As String = a.ImageRuntimeVersion

From the command line, starting in v2.0, ildasm.exe will show it if you double-click on "MANIFEST" and look for "Metadata version". Determining an Image’s CLR Version

从命令行开始,从v2.0开始,ildasm。如果双击“MANIFEST”并查找“元数据版本”,exe将显示它。确定图像的CLR版本。

#6


11  

Use ILSpy http://ilspy.net/

使用ILSpy http://ilspy.net/

open source, free, definitely an option since now reflector is paid.

开源,免费,绝对是一个选择,因为现在反射器是付费的。

#7


10  

Yet another option via Visual Studio, add a reference to the DLL to any project, then right-clicking on the new reference and click Properties, you can see what you are looking for in Runtime version:

通过Visual Studio的另一个选项,向任何项目添加一个DLL的引用,然后右键单击新的引用并单击Properties,您可以看到在运行时版本中您要查找的内容:

确定。net框架版本的dll。

#8


8  

Decompile it with ILDASM, and look at the version of mscorlib that is being referenced (should be pretty much right at the top).

将它与ILDASM进行反编译,并查看正在引用的mscorlib版本(在顶部应该相当正确)。

#9


8  

Just simply

仅仅

var tar = (TargetFrameworkAttribute)Assembly
          .LoadFrom("yoursAssembly.dll")
          .GetCustomAttributes(typeof(TargetFrameworkAttribute)).First();

#1


46  

Load it into Reflector and see what it references?

把它加载到反射器中,看看它的引用是什么?

for example:

例如:

确定。net框架版本的dll。

#2


76  

In PowerShell you can use the following to get the target runtime:

在PowerShell中,您可以使用以下命令获取目标运行时:

$path = "C:\Some.dll"
[Reflection.Assembly]::ReflectionOnlyLoadFrom($path).ImageRuntimeVersion

I adapted this to PowerShell from Ben Griswold's answer.

我根据本·格里斯沃尔德(Ben Griswold)的答案改编了PowerShell。

If you want to know the target framework version specified in Visual Studio, use:

如果您想知道Visual Studio中指定的目标框架版本,请使用:

$path = "C:\Some.dll"
[Reflection.Assembly]::ReflectionOnlyLoadFrom($path).CustomAttributes |
Where-Object {$_.AttributeType.Name -eq "TargetFrameworkAttribute" } | 
Select-Object -ExpandProperty ConstructorArguments | 
Select-Object -ExpandProperty value

You should get something like

你应该得到一些类似的东西。

.NETFramework,Version=v4.5.2

= v4.5.2 .NETFramework,版本

#3


56  

dotPeek is a great (free) tool to show this information.

dotPeek是一个很好的(免费的)工具来显示这些信息。

If you are having a few issues getting hold of Reflector then this is a good alternative.

如果你在获得反射器方面有一些问题,那么这是一个很好的选择。

确定。net框架版本的dll。

#4


41  

You can use ILDASM...

您可以使用ILDASM……

ildasm.exe C:\foo.dll /metadata[=MDHEADER] /text /noil

and check for the 'Metadata section' in the output. It would be something like this:

检查输出中的“元数据”部分。大概是这样的:

Metadata section: 0x424a5342, version: 1.1, extra: 0, version len: 12, version: v4.0.30319

元数据部分:0x424a5342,版本:1.1,额外:0,版本len: 12,版本:v4.0.30319。

The 'version' tag will tell you the .NET Framework version. In the above example it is 4.0.30319

“版本”标签会告诉你。net框架版本。在上面的示例中,它是4.0.30319

#5


13  

You have a few options: To get it programmatically, from managed code, use Assembly.ImageRuntimeVersion:

您有几个选项:要以编程方式从托管代码中获得它,请使用Assembly.ImageRuntimeVersion:

Dim a As Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom("C:\path\assembly.dll")
Dim s As String = a.ImageRuntimeVersion

From the command line, starting in v2.0, ildasm.exe will show it if you double-click on "MANIFEST" and look for "Metadata version". Determining an Image’s CLR Version

从命令行开始,从v2.0开始,ildasm。如果双击“MANIFEST”并查找“元数据版本”,exe将显示它。确定图像的CLR版本。

#6


11  

Use ILSpy http://ilspy.net/

使用ILSpy http://ilspy.net/

open source, free, definitely an option since now reflector is paid.

开源,免费,绝对是一个选择,因为现在反射器是付费的。

#7


10  

Yet another option via Visual Studio, add a reference to the DLL to any project, then right-clicking on the new reference and click Properties, you can see what you are looking for in Runtime version:

通过Visual Studio的另一个选项,向任何项目添加一个DLL的引用,然后右键单击新的引用并单击Properties,您可以看到在运行时版本中您要查找的内容:

确定。net框架版本的dll。

#8


8  

Decompile it with ILDASM, and look at the version of mscorlib that is being referenced (should be pretty much right at the top).

将它与ILDASM进行反编译,并查看正在引用的mscorlib版本(在顶部应该相当正确)。

#9


8  

Just simply

仅仅

var tar = (TargetFrameworkAttribute)Assembly
          .LoadFrom("yoursAssembly.dll")
          .GetCustomAttributes(typeof(TargetFrameworkAttribute)).First();