Check if an Assembly Is 64 Bit
Determines whether the specified .NET assembly is compiled for a 64-bit platform.
This function uses the GetPEKind method to inspect the assembly’s PE header and determine the platform target. It returns False if the analysis fails or if the assembly is not 64-bit.
VB
Function IsAssembly64Bit(assembly As Assembly) As Boolean
Try
Dim peKind As PortableExecutableKinds
Dim machine As ImageFileMachine
' Get the platform type
assembly.ManifestModule.GetPEKind(peKind, machine)
' Check if it's x64
Return (peKind And PortableExecutableKinds.PE32Plus) <> 0 AndAlso
(machine = ImageFileMachine.AMD64 OrElse machine = ImageFileMachine.IA64)
Catch ex As Exception
Console.WriteLine("Error during assembly analisys: " & ex.Message)
Return False
End Try
End Function