一个纯粹的 C# CIL 解释器,用于在 IL2CPP (Unity) 平台上加载和执行托管代码。
A pure C# CIL interpreter designed to load and execute managed code on AOT/IL2CPP (Unity) platforms.
Being able to run dynamically loaded code can be a great thing, especially in game development as it allows for modding support and much more. Combine it iwith a runtime compiler like Roslyn and the possibilities are practically endless. Unfortunately, it is not possible to natviley load code dynamically if AOT is used, since JIT is not available. dotnow was created to make this possible by interpreting the managed CIL instructions in software, and replicating the runtime environment.
The end goal is to create a performant and feature complete runtime for managed code with support for AOT platforms including IL2CPP (Unity).
dotnow is still very in early development although it is able to run most CIL code in its current form. There are however a few inherant limitations to the project:
dotnow can be installed using the Unity package manager via the following git URL. Follow instructions here for installing git packages in Unity.https://github.com/scottyboy805/dotnow-interpreter.git
Alternativley check the releases section for .unitypackage versions.
A dotnow AppDomain is required as a container for all interpreted code, and 1 or more assemblies can be loaded into the same domain. It is also possible to have multiple app domains in the same process.
dotnow implementes the full System.Reflection interface, meaning that once an assembly is loaded, you can use the normal reflection API to find types and invoke members.
…dotnow assemblies can also be unloaded without destroying the domain via the assemby load context. The domain caches all interop members, so it makes sense to reuse it if possible:
// Get the load context for a dotnow assembly
AssemblyLoadContext loadContext = domain.GetLoadContext(assembly);
// Now can can dispose just this context, and the domai and any other assemblies will remain in memory
loadContext.Dispose();Take a look at the wiki for more samples.
You can sponsor this project to help it grow :heart: Sponsor
暂无开放 Issues,或尚未同步最近议题。