Question

I'm using Assembly.Load() and then EntryPoint.Invoke(null, null) in order to run a .NET assembly in memory. This works, unless if the host process is x86 and the executed assembly is AnyCPU. In this case, the executed assembly gets executed in x86 context and therefore malfunctions.

Is there a way to execute the Assemly object in an AnyCPU context, even if the host process is x86?

Was it helpful?

Solution

Executing the assembly in AnyCPU context doesn't really make sense. An assembly that targeted AnyCPU will JIT to 64-bit if loaded into a 64-bit process and 32-bit for a 32-bit process. If this assembly is dependent on the host process being 64-bit then it's platform target should be x64 as opposed to Any CPU.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top