Garbage collector Message; how to solve it?
-
I am using a keyboard hook to stop most if not all the keys on the keyboard but i am getting this message: CallbackOnCollectedDelegate was detected Message: A callback was made on a garbage collected delegate of type 'Client!KeyboardHook+HookHandlerDelegate::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. any ideas how to solve it?
Luis E Tineo S
-
I am using a keyboard hook to stop most if not all the keys on the keyboard but i am getting this message: CallbackOnCollectedDelegate was detected Message: A callback was made on a garbage collected delegate of type 'Client!KeyboardHook+HookHandlerDelegate::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. any ideas how to solve it?
Luis E Tineo S
Error messages are so informative these days, that it almost gets too easy. You have the solution handed to you in the error message already: "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." You have thrown away your reference to the delegate. Don't do that.
Experience is the sum of all the mistakes you have done.