如何确定.NET程序集是专为x86或x64?专为、程序、NET

2023-09-02 10:15:30 作者:盏中柳色浅

我有.NET程序集的任意列表。

I've got an arbitrary list of .NET assemblies.

我需要以编程方式检查每个DLL是专为86(而不是到x64或任何CPU)。这可能吗?

I need to programmatically check if each DLL was built for x86 (as opposed to x64 or Any CPU). Is this possible?

推荐答案

System.Reflection.AssemblyName.GetAssemblyName(字符串assemblyFile)

您可以检查从返回的AssemblyName实例集元数据:

You can examine assembly metadata from the returned AssemblyName instance:


[36] C:> [reflection.assemblyname]::GetAssemblyName("${pwd}Microsoft.GLEE.dll") | fl

Name                  : Microsoft.GLEE
Version               : 1.0.0.0
CultureInfo           :
CodeBase              : file:///C:/projects/powershell/BuildAnalyzer/...
EscapedCodeBase       : file:///C:/projects/powershell/BuildAnalyzer/...
ProcessorArchitecture : MSIL
Flags                 : PublicKey
HashAlgorithm         : SHA1
VersionCompatibility  : SameMachine
KeyPair               :
FullName              : Microsoft.GLEE, Version=1.0.0.0, Culture=neut... 

下面,ProcessorArchitecture确定目标平台。

我使用的PowerShell在这个例子中要调用的方法。

I'm using PowerShell in this example to call the method.