有没有办法启动用托管语言编写的代码?
这个问题说明了一切。我可以将 C# 编译为本机代码并启动它吗?我知道宇宙和奇点,但我想知道是否有更新的技术或工具。谢谢。
The question says it all. Can I compile C# to native code and boot it? I know of Cosmos and Singularity, but I was wondering if there are more recent techniques or tools. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
显然你可以使用 Mono 编译为本机代码:
http://www.mono -project.com/Mono:Runtime#Ahead-of-time_compilation
不过,您将无法用它编写操作系统。用 C# 编写整个操作系统是不可能的,Cosmos 和 Singularity 将有部分不是托管代码。
或者,当然,您可以将代码设置为在 Windows 启动时启动 - 一旦 Windows 启动到登录屏幕及其他屏幕,.NET 应用程序就会正常运行。
Apparently you can compile to native code using Mono:
http://www.mono-project.com/Mono:Runtime#Ahead-of-time_compilation
Still, you won't be able to write an OS with that. Its impossible to write an entire OS in C#, Cosmos and Singularity will have portions that aren't managed code.
Or of course, you can set your code to boot at Windows Startup - .NET applications will run just fine once Windows has booted up to the login screen and beyond.
“启动它”到底是什么意思...如果你的意思是“在机器上作为操作系统启动”,你需要设置一个启动加载程序并自己重写大部分 c# 函数。您还必须使用较低级语言(汇编/c[++]/等)设置所有特定于机器的功能。基本上,如果不做大量的工作,就无法让它自行启动。
What exactly do you mean by "boot it"... If you mean "boot on a machine as an OS" you would need to set up a bootloader and re-write most of the c# functions yourself. You would also have to set up all the machine-specific features from a lower-level language (assembly/c[++]/etc). Basically, there's no way to have it boot by itself without a significant amount of work.
一种选择是创建一个设置为随系统启动的 Windows 服务。我相信还有其他方法可以实现这一点,但这可能是“最简单的”。
One option would be to author a windows service that is set to start with the system. I believe there are other ways to accomplish this but this maybe 'the easiest'.