07th-mod / 07th-mod/higurashi-assembly
[Wine][Ch.8] InvalidCastException on startup when registering key hooks
- 主要语言
- C#
- 星标
- 12
- 派生
- 12
- PR 合并指标
- 30 天内没有已合并 PR
描述
I saw this error on the logs, likely due to lack of error checking in `KeyHook.cs`
```c#
InvalidCastException: Cannot cast from source type to destination type.
at System.Diagnostics.ProcessModuleCollection.get_Item (Int32 index) [0x00000] in :0
at System.Diagnostics.Process.get_MainModule () [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_MainModule ()
at Assets.Scripts.Core.KeyHook.SetHook (Assets.Scripts.Core.LowLevelKeyboardProc proc) [0x00000] in :0
at Assets.Scripts.Core.KeyHook..ctor () [0x00000] in :0
at Assets.Scripts.Core.GameSystem.Initialize () [0x00000] in :0
at Assets.Scripts.Core.GameSystem.CheckInitialization () [0x00000] in :0
at Assets.Scripts.Core.GameSystem.Update () [0x00000] in :0
```
Full Log: [log.txt](https://github.com/user-attachments/files/16728938/log.txt)
贡献指南
这个仓库没有索引到贡献指南
调研方向
The error originates in Assets/Scripts/Core/KeyHook.cs, specifically in the SetHook method and constructor. Examine the Process.MainModule usage and the LowLevelKeyboardProc delegate. Check the full log for additional context. The fix likely involves adding error handling for the InvalidCastException when retrieving the main module, possibly due to Wine compatibility. Test the startup after changes to ensure the hook registers without crashing.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- desktop-dev
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100