Skip to content

AssemblyX.OnAssemblyResolve 引发 StackOverflowException #181

Description

@Soar360

在 Release 模式下,如果使用了 Cube 或者 星尘,则会在启动时报错:StackOverflowException

经过分析:


调用链构成了循环递归:
1.	FileSystemWatcher 构造函数(在 NewLife.Configuration.FileConfigProvider.InitWatcher 中创建)抛出/校验路径,需要从 System.IO.FileSystem.Watcher.dll 的资源中读取本地化字符串(SR.GetResourceString)。
2.	由于当前 UI 文化(很可能是 zh-CN)不是 invariant,CLR 试图加载卫星程序集 System.IO.FileSystem.Watcher.resources。
3.	CLR 找不到该卫星程序集,触发 AppDomain.AssemblyResolve 事件,调用了 NewLife 注册的处理器 NewLife.Reflection.AssemblyX.OnAssemblyResolve。
4.	该处理器内部访问 Log → Level → Config<Setting>.Current → FileConfigProvider.Bind → InitWatcher → 再次 new FileSystemWatcher(...) → 再次需要资源字符串 → 再次触发 AssemblyResolve → ……
栈跟踪显示该 18 帧的循环重复了 217 次,最终爆栈。

请先定位问题,确认问题原因。编写单元测试复现异常,然后修复,并继续运行测试。

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions