views:

129

answers:

1

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:

A: 

Try using Assembly.ReflectionOnlyLoad. This will let you load the assembly into memory - but won't execute any code in it. that will allow x64 assemblies to be loaded for reflection in an x86 process.

Paul Alexander