I'm writing a installation validation tool for our product and I need to retrieve some PE information from several installed assemblies. No matter what the platform our product is installed on, we ship AMD64, x86 and MSIL assemblies to certain locations to let the user create deployment projects for these the platforms.
The problem is that, using the following code:
Module manifestModule = Assembly.LoadFile(fileName).ManifestModule;
ImageFileMachine m;
PortableExecutableKinds pe;
manifestModule.GetPEKind(out pe, out m);
Assembly.LoadFile(...) will break if the application is running as x86 and trying to load an AMD64 assembly or viceversa.
I found these related-but-not-quite:
- http://stackoverflow.com/questions/270531/how-to-determine-if-net-assembly-was-built-for-x86-or-x64 It doesn't say how could you dig onto a AMD64 assembly from an x86 process.
- http://stackoverflow.com/questions/197951/how-can-i-determine-for-which-platform-an-executable-is-compiled I really really need to get both an ImageFileMachine and a PEKinds because of the big mix of assemblies we have and the properties we need to determine.