Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top