I need to determine programmatically whether an assembly is x86, x64 or AnyCPU? There is an almost identical question, but the solution that it provides
Ass
This question's been covered already:
But the answers are incomplete, suggesting use of Assembly.LoadFrom
. That's a terrible idea, since it will run code from the assembly, in addition to failing if the bitness doesn't match your process.
Instead, you should use Assembly.ReflectionOnlyLoadFrom. This lets you read the metadata without actually loading any code, and therefore there's no need for the architecture to be correct.
Solution how to determinate this just by code without reflection nor thirdparty SW can be found here: How to determine if a .NET assembly was built with platform target AnyCPU, AnyCPU Prefer32-bit, x86, x64 without using reflection and third party SW