07th-mod / 07th-mod/higurashi-assembly
[Wine][Ch.8] InvalidCastException on startup when registering key hooks
- Langage dominant
- C#
- Étoiles
- 12
- Forks
- 12
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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)
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp
- Domaine
- desktop-dev
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100