clr-activation-debugging
它能做什么
这项技能分析较旧的 .NET Framework 应用为何加载了错误的运行时,或无法加载运行时。适合在 Windows 上排查旧版 .NET Framework 应用的开发者和管理员。
适用场景
- ✓当 .NET Framework 进程因找不到要使用的运行时而报错时。
- ✓当应用启动了错误的 .NET Framework 版本的时候。
- ✓当 .NET 3.5 功能的安装对话框意外出现或未能出现的时候。
技能链接
https://github.com/dotnet/skills/blob/main/plugins/dotnet-diag/skills/clr-activation-debugging/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 .NET Framework 应用启动的是 2.0 运行时,而不是 4.0。请读取激活日志并告诉我原因。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会读取垫片(shim)生成的运行时加载日志,逐一跟踪垫片所做的每个决定,并说明选择了哪个运行时以及原因。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
CLR Activation Debugging
Diagnose .NET Framework runtime activation issues by analyzing CLR activation logs (CLRLoad logs) produced by the shim (mscoree.dll). These logs record every decision the shim makes when selecting and loading a CLR version.
When to Use
- A process fails to load the CLR at all ("Unable to find a version of the runtime to use")
- The shim picks the wrong CLR version (e.g., v2.0 instead of v4.0)
- Unexpected .NET 3.5 Feature-on-Demand (FOD) install dialogs appear
- FOD dialogs are expected but do NOT appear
- Both CLR v2 and CLR v4 load into the same process, causing failures
- A COM object fails to activate because the shim can't resolve the runtime
- Legacy hosting APIs (CorBindToRuntime) bind to an unexpected version
When Not to Use
- Modern .NET (CoreCLR / .NET 5+) — this skill covers .NET Framework only (the mscoree.dll shim)
- Assembly binding failures — use Fusion logs (fuslogvw.exe), not CLR activation logs
- Runtime crashes after the CLR has loaded — activation succeeded; the problem is elsewhere
Background
The Shim Architecture
The .NET Framework shim has two layers:
- mscoree.dll (the "shell shim") — the public-facing DLL that is the registered
InprocServer32for CLR-hosted COM objects and the entry point for_CorExeMain, legacy APIs, etc. - mscoreei.dll — the actual shim implementation where the runtime selection logic, logging, and activation decisions live. mscoree.dll forwards into mscoreei.dll.
When reading logs, the caller-name:mscoreei.dll in FOD command lines reflects this — it's mscoreei.dll doing the work.
.NET 3.5 / v2.0.50727 Version Mapping
.NET 2.0, 3.0, and 3.5 all share the same CLR runtime version: v2.0.50727. The "3.0" and "3.5" releases were library additions on top of CLR v2.0. For activation purposes, they are all "v2.0.50727." When the shim resolves to v2.0.50727 or FOD offers to install "NetFx3", it's installing the CLR v2.0 runtime (plus the 3.0/3.5 libraries). Similarly, CLR v4.0 (v4.0.30319) covers all .NET Framework versions from 4.0 through 4.8.x.
.NET 3.5 Availability on Recent Windows
On recent Windows versions (Windows 11 Insider Preview Build 27965 and future platform releases), .NET Framework 3.5 is no longer available as a Windows optional component (Feature-on-Demand). It must be installed from a standalone MSI. This means the FOD dialog (fondue.exe /enable-feature:NetFx3) will not succeed on these systems even if it fires. On Windows 10 and Windows 11 through 25H2, FOD remains available. .NET Framework 3.5 reaches end of support on January 9, 2029.
Shim HRESULT Codes
When the shim fails, it returns specific HRESULTs in the 0x8013xxxx range. These are the errors you'll see from callers (not in the activation logs themselves, which log human-readable messages):
| HRESULT | Symbol | Meaning |
|---|---|---|
0x80131700 |
CLR_E_SHIM_RUNTIMELOAD |
Cannot find or load a suitable runtime version. This is the most common shim error — it's what callers see when capped legacy activation fails on a v4-only machine. |
0x80131701 |
CLR_E_SHIM_RUNTIMEEXPORT |
Found a runtime but failed to get a required export or interface from it. |
0x80131702 |
CLR_E_SHIM_INSTALLROOT |
The .NET Framework install root is missing or invalid in the registry. |
0x80131703 |
CLR_E_SHIM_INSTALLCOMP |
A required component of the installation is missing. |
0x80131704 |
CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND |
A different runtime is already bound as the legacy runtime. A legacy API tried to bind to a version that conflicts with the one already chosen. |
0x80131705 |
CLR_E_SHIM_SHUTDOWNINPROGRESS |
The shim is shutting down and cannot service the request. |
If a user reports one of these HRESULTs (especially 0x80131700), CLR activation logs are the right diagnostic tool.
Prerequisites
CLR activation logging must be enabled to produce log files. If the user doesn't have logs yet, instruct them to enable logging:
Via environment variable (recommended — scoped to current session):
set COMPLUS_CLRLoadLogDir=C:\CLRLoadLogs
Via registry (machine-wide — affects all .NET Framework processes):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
CLRLoadLogDir = "C:\CLRLoadLogs" (REG_SZ)
On 64-bit systems, also set under Wow6432Node if 32-bit processes are involved.
⚠️ The log directory must already exist. The shim will n
常见问题
它涵盖现代 .NET 吗?
不涵盖。它只针对 .NET Framework,不包括 CoreCLR 或 .NET 5 及以后的版本。
它能处理程序集加载错误吗?
不能。这些需要其他日志工具,例如 Fusion 日志查看器。
什么是垫片(shim)?
它是系统中的 DLL,负责为某个进程决定加载哪个 .NET Framework 运行时。
详情
作者的原始描述
Diagnoses .NET Framework CLR activation issues using CLR activation logs (CLRLoad logs) produced by mscoree.dll. Use when: the shim picks the wrong runtime, fails to load any runtime, shows unexpected .NET 3.5 Feature-on-Demand (FOD) dialogs, unexpectedly does NOT show FOD dialogs, loads both v2 and v4 into the same process causing failures, or any time someone is wondering "what is happening with .NET Framework activation?"
repo: dotnet/skills
热度
- GitHub 星标
- 5.8k
- 排名
- #14576
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
create-custom-agent
5.8k帮你的智能体创建 VS Code 自定义智能体文件,为每个智能体设置专属工具、指令以及向其他智能体的交接。
create-skill
5.8k帮你的智能体创建新的智能体技能,包括有效的名称、清晰的触发描述,以及符合标准的 SKILL.md 文件。
csharp-scripts
5.8k帮你的智能体通过 .NET 命令行工具以单个文件运行小型 C# 程序,无需创建完整项目。
dotnet-pinvoke
5.8k帮你的智能体在 .NET 中正确调用原生 C 或 C++ 库,涵盖函数签名、字符串处理、内存和安全句柄。