Tim*_*ong 31 .net x86-64 visual-studio
发现(无法访问源项目).NET程序集DLL是否编译为"x86","x64"或"任何CPU"的最简单方法是什么?
更新:命令行实用程序足以满足我的直接需求,但仅仅是为了完整性,如果有人想告诉我如何以编程方式执行它,那么这也是有意义的,我敢肯定.
adr*_*nks 47
如果您只想在给定的dll上找到它,那么您可以使用属于Windows SDK 的CorFlags工具:
CorFlags.exe assembly.dll
Run Code Online (Sandbox Code Playgroud)
如果要使用代码执行此操作,请查看Module类的GetPEKind方法:
Assembly assembly = Assembly.LoadFrom("path to dll");
PortableExecutableKinds peKind;
ImageFileMachine imageFileMachine;
assembly.ManifestModule.GetPEKind(out peKind, out imageFileMachine)
Run Code Online (Sandbox Code Playgroud)
然后,您需要检查peKind
以检查其值.请参阅MSDN文档的PortableExecutableKinds
更多信息.
Pet*_*ale 13
谢谢阿德里安!我已经在PowerShell中重写了代码片段,因此我可以在服务器上使用它.
#USAGE #1
# Get-Bitness (dir *.dll | select -first 1)
#USAGE #2
# Get-Bitness "C:\vs\projects\bestprojectever\bin\debug\mysweetproj.dll"
function Get-Bitness([System.IO.FileInfo]$assemblyFile)
{
$peKinds = new-object Reflection.PortableExecutableKinds
$imageFileMachine = new-object Reflection.ImageFileMachine
$a = [Reflection.Assembly]::LoadFile($assemblyFile.Fullname)
$a.ManifestModule.GetPEKind([ref]$peKinds, [ref]$imageFileMachine)
return $peKinds
}
Run Code Online (Sandbox Code Playgroud)