Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

Natasha

> 编程语言
Open source

基于 Roslyn 的 C# 动态程序集构建库,该库允许开发者在运行时使用 C# 代码构建域 / 程序集 / 类 / 结构体 / 枚举 / 接口 / 方法等,使得程序在运行的时候可以增加新的模块及功能。Natasha 集成了域管理/插件管理,可以实现域隔离,域卸载,热拔插等功能。 该库遵循完整的编译流程,提供完整的错误

1.6K stars0 likes0 views
WebsiteGitHub

About

基于 Roslyn 的 C# 动态程序集构建库,该库允许开发者在运行时使用 C# 代码构建域 / 程序集 / 类 / 结构体 / 枚举 / 接口 / 方法等,使得程序在运行的时候可以增加新的模块及功能。Natasha 集成了域管理/插件管理,可以实现域隔离,域卸载,热拔插等功能。 该库遵循完整的编译流程,提供完整的错误

中文 | English

你们的反馈是我的动力,文档还有很多不足之处;

当你看完文档之后仍然不知道如何实现你的需求,您可以查看 FAQ 或者在issue中提出你的需求。


# Natasha


    基于 [Roslyn](https://github.com/dotnet/roslyn) 的 C# 动态程序集构建库,该库允许开发者在运行时使用 C# 代码构建域 / 程序集 / 类 / 结构体 / 枚举 / 接口 / 方法等,使得程序在运行的时候可以增加新的模块及功能。Natasha 集成了域管理/插件管理,可以实现域隔离,域卸载,热拔插等功能。 该库遵循完整的编译流程,提供完整的错误提示, 可自动添加引用,完善的数据结构构建模板让开发者只专注于程序集脚本的编写,兼容 netstandard2.0, 跨平台,统一、简便的链式 API。 且我们会尽快修复您的问题及回复您的 [issue](https://github.com/dotnetcore/Natasha/issues/new) . [这里有更多的使用文档](https://natasha.dotnetcore.xyz/zh-Hans/docs)
## ClawHub 安装 [Skill](https://clawhub.ai/skills?q=csharp-dotnetcore-natasha): `npx clawhub install csharp-dotnetcore-natasha` ## 使用 引入包 `DotNetCore.Natasha.CSharp.Compiler` 编译单元主体
引入包 `DotNetCore.Natasha.CSharp.Compiler.Domain` 编译域 (netcore3.1+) #### 初始化(v9) ```cs NatashaManagement //获取链式构造器 .GetInitializer() //使用引用程序集中的命名空间 .WithMemoryUsing() //使用内存中的元数据 .WithMemoryReference() //注册域构造器 .Preheating(); ``` #### 动态编译 ```cs AssemblyCSharpBuilder assemblyCSharp = new(); assemblyCSharp.ConfigLoadContext(ctx => ctx.AddReferenceAndUsingCode()); assemblyCSharp.Add("public class A{public void Show(){}}"); assemblyCSharp.LogCompilationEvent += (log) => { Console.WriteLine(log.ToString()); }; var newAssembly = assemblyCSharp.GetAssembly(); ```
## 赞助 关闭打赏 #### 捐助明细 - L*u 50 元 - 亮 20 元 - 升讯威在线客服系统 5 元 - Json-jh [尊敬的博客园VIP会员] 22 元 - [Newbe俞佬](https://github.com/newbe36524) 90.2 元 - 崔星星 17 元 - Money 100 元 - [Newbe俞佬](https://github.com/newbe36524) 200 元 - iNeuOS工业互联网平台 100 元 - 老萌 30 元 - ****天下 10 元 - 文航 5 元 - TonyQu 10 元 - Rwing 20 元 感谢老铁们的支持,感激不尽 。
--------------------- ## License

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •L*u 50 元
  • •升讯威在线客服系统 5 元
  • •Json-jh [尊敬的博客园VIP会员] 22 元
  • •Newbe俞佬 90.2 元
  • •崔星星 17 元
  • •Money 100 元
  • •Newbe俞佬 200 元
  • •iNeuOS工业互联网平台 100 元
  • •TonyQu 10 元
  • •Rwing 20 元

> Tags

C#csharpdotnetcoredynamichacktoberfest

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

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