Search code examples
.netclrcil

Is there a CLR that runs on the CLR?


I was wondering if there was a .NET-compatible CLR that was implemented using the CLI (common language infrastructure), e.g., using .NET itself, or at least if there were any resources that would help with building one.

Basically, something like a .NET program that loads assemblies as MemoryStreams, parses the bytecode, constructs the types, and executes the instructions. Optionally, it can JIT-compile to standard IL using Reflection.Emit or however.

I don't want to compile a .NET language to be run by the original CLR. I want a CLR that's written in a .NET language (not unmanaged C++ or C as it usually is) and runs CIL. If done right, it should be able to run itself.

Any thoughts on using Mono.Cecil for this kind of thing?


Solution

  • I don't think there are currently any standalone .net VMs that are self hosting but both Cosmos and SharpOS are .net runtimes written in C#.

    It may be possible to reuse some of their runtime code to extra a standalone runtime. Cosmos can be used to host a custom application on boot: http://www.codeproject.com/KB/system/CosmosIntro.aspx