> For the complete documentation index, see [llms.txt](https://docs.zongsoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zongsoft.com/overview/pluginization.md).

# 插件化

Zongsoft 插件化应用的基本概念和运行方式。

插件化是 Zongsoft 的核心特征。一个插件式应用由宿主程序和多个插件共同组成，宿主负责启动和承载，插件负责提供业务能力与扩展点。

## 插件是什么

在 Zongsoft 中，插件不是单个程序集的别名，而是一组文件和元数据的组合。最常见的插件内容包括：

* 插件描述文件 `*.plugin`。
* 插件程序集 `*.dll`。
* 选项配置 `*.option`。
* 数据映射 `*.mapping`。
* 本地化资源目录，如 `zh-Hans`、`zh-CN`。
* 证书、模板、静态资源等附属文件。

## 插件如何加载

宿主程序启动后，插件框架会扫描宿主目录下的 `plugins/` 目录，读取插件描述文件，加载程序集并建立应用上下文。插件可以注册服务、命令、事件处理器、Web 控制器或其它模块能力。

## 为什么使用插件化

插件化解决的是大型业务系统的组织问题：

* 业务模块可以独立发布。
* 运行宿主可以保持轻量和稳定。
* 不同环境可以通过部署文件组合不同插件。
* 不依赖特定交互或协议的业务插件可以在不同宿主形态中复用；控制器及 ASP.NET 中间件等则必须附属 Web 宿主。
* 配置、映射和资源可以随插件一起部署。

## 插件化设计专题

以下文章结合论坛模块的实际实现，讨论设计选择及其代价。建议按顺序阅读，也可以从正在面对的问题进入。配图中的“设计示意”表示待设计的能力或方案，具体实现状态以正文说明为准。

1. [为什么需要插件化](/overview/pluginization/why-pluginization.md)：巨石应用的痛点，分层、切块与按业务组织目录带来的变化。
2. [从业务变化确定模块边界](/overview/pluginization/business-boundaries.md)：以审核、正文和统计的共同变化判断业务归属。
3. [让业务能力跨宿主复用](/overview/pluginization/host-independent-business.md)：明确业务动作、入口适配、身份和生命周期的分工。
4. [把扩展点设计成协作契约](/overview/pluginization/extension-contracts.md)：设计扩展路径、服务调用、命名和失败语义。
5. [从局部改造到可验证的插件交付](/overview/pluginization/evolutionary-delivery.md)：验证发布组合，并处理数据兼容与进程拆分的取舍。

## 文档阅读建议

先阅读 [插件框架](/framework/plugins.md) 理解应用模型，再阅读 [部署第一个插件](/get-started/deploy-first-plugin.md) 了解插件如何进入宿主。需要深入数据访问时，再进入 [数据引擎](/framework/data.md)。

## 扩展点也是契约

一个插件提供服务或集合挂载点，另一个插件声明依赖并贡献实现。依赖不仅决定程序集可见性，也说明“需要先有哪些组件才能工作”。扩展路径、服务名和配置键应像公开 API 一样维护，变更时同步消费者。

插件化不等于任意热替换，也不等于进程级隔离。加载到同一宿主的组件共享进程资源，版本冲突或错误[工作器](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Components/IWorker.cs)可能影响整个应用。需要独立故障边界时，应考虑独立进程和通信协议。

背景术语见[基础概念](/overview/concepts.md)，完整组合路径见[首个业务插件](/get-started/first-business-plugin.md)。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.zongsoft.com/overview/pluginization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
