百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

dotnow-interpreter

> 编程语言
开源

一个纯粹的 C# CIL 解释器,用于在 IL2CPP (Unity) 平台上加载和执行托管代码。

181 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个纯粹的 C# CIL 解释器,用于在 IL2CPP (Unity) 平台上加载和执行托管代码。

dotnow Interpreter

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.

Project Goals

The end goal is to create a performant and feature complete runtime for managed code with support for AOT platforms including IL2CPP (Unity).

  • Full support for generic types and members.
  • Full reflection of interpreted types, as if they were loaded nativley.
  • Implement all CIL instructions and runtime features.
  • Support for inheritance of interop types (via proxy bindings).
  • Execute code as fast as is reasonably possible.
  • Support for debugging.

Dependencies

  • System.Reflection.Metadata (8.0.0.0) or newer. Used to read managed pe assembly images and metadata.
  • (Optional) Microsoft.CodeAnalysis.CSharp (4.13.0.0) or newer. Only required for the code gen tool to generate bindings for interop API's.

Limitations

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:

  • In order for user types to derive from interpreted types defined in external assemblies, a proxy binding must be created ahead of time.
  • Invoking interop methods can be very slow unless a direct call binding is implemented ahead of time.
  • Code stripping can cause issues in builds. You can use link.xml or direct call bindings to get around the problem.
  • AOT code for some generic types may not be emitted at build, causing runtime errors. For example If 'List`(int)' is not used inside the main project at any time but runtime interpreted code does use this generic type, it will cause a runtime exception stating (correctly) that no AOT code was generated. The workarounds for this are nasty hacks at the moment and involve declaring variables for all potential generic combinations ahead or time.

Installation

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.

Usage

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:

cs
// 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.

Demos

  • Snake: A simple snake game that is dynamically loaded and interpreted on Unity WebGL with IL2CPP backend. Demo scripts use arrays, collections, generics, enums and derive from MonoBehaviour. Find the demo game here. Find the demo project in 'ExampleProjects/SnakeExample' (Game runtime scripts - dynamically loaded) and 'Assets/Examples/Snake' (Loading and setup code).

Sponsors

You can sponsor this project to help it grow :heart: Sponsor

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言