相关疑难解决方法(0)

检测到globalKeyboardHook中的CallbackOnCollectedDelegate

我正在使用全局键盘钩子类.此类允许检查键盘键是否按下任何位置.过了一段时间我有一个错误:

        **CallbackOnCollectedDelegate was detected**

A callback was made on a garbage collected delegate of type 'Browser!Utilities.globalKeyboardHook+keyboardHookProc::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Run Code Online (Sandbox Code Playgroud)

这是globalkeyboardHook类:

        public delegate int keyboardHookProc(int code, int wParam, ref keyboardHookStruct lParam);

        public struct keyboardHookStruct
        {
            public int vkCode;
            public int scanCode;
            public int flags;
            public int time;
            public int dwExtraInfo; …
Run Code Online (Sandbox Code Playgroud)

c#

13
推荐指数
1
解决办法
7015
查看次数

标签 统计

c# ×1