力86 CLR上的“任何CPU”.NET程序集程序、CLR、NET、CPU

2023-09-07 23:01:49 作者:男宠

在.NET中,平台目标:任何CPU编译器选项允许.NET程序集为64&NBSP运行;在x64机器上的位,和32 NBSP;位的x86机器上。也可以强制装配为86用在x64机器上运行平台目标:86。编译器选项

In .NET, the 'Platform Target: Any CPU' compiler option allows a .NET assembly to run as 64 bit on a x64 machine, and 32 bit on an x86 machine. It is also possible to force an assembly to run as x86 on an x64 machine using the 'Platform Target: x86' compiler option.

是否有可能运行与'任何CPU'标志的组件,但是确定它是否应该在x86或x64 CLR上运行?通常情况下这个决定是由CLR / OS加载程序制作(这是我的理解)基于底层系统的位数。

Is it possible to run an assembly with the 'Any CPU' flag, but determine whether it should be run in the x86 or x64 CLR? Normally this decision is made by the CLR/OS Loader (as is my understanding) based on the bitness of the underlying system.

我想写一个C#.NET应用程序,可以用(读:注资code到)进行交互的其他正在运行的进程。 64进程仅注入到其它的x64进程,和相同的带86。理想情况下,我想借此JIT编译和的任何CPU的优势的选项,以允许一个单一的应用程序可用于注入无论是64或86的过程(在x64机器上)。

I am trying to write a C# .NET application that can interact with (read: inject code into) other running processes. x64 processes can only inject into other x64 processes, and the same with x86. Ideally, I would like to take advantage of JIT compilation and the Any CPU option to allow a single application to be used to inject into either x64 or x86 processes (on an x64 machine).

的想法是,该应用程序将被编译成的任何CPU 的。在基于x64的机器,它将为64运行。如果目标进程是86,它应该重新启动本身,迫使CLR来运行它的x86。这可能吗?

The idea is that the application would be compiled as Any CPU. On an x64 machine, it would run as x64. If the target process is x86, it should relaunch itself, forcing the CLR to run it as x86. Is this possible?

推荐答案

您可以找到如何应用程序将运行并静态使用的