An attempt was made to retrieve a GCHandle from an invalid IntPtr cookie ( 1$x). The cookie was most likely invalid because ...

An attempt was made to retrieve a GCHandle from an invalid IntPtr cookie (0x%1$x). The cookie was most likely invalid because the cookie does not represent a GCHandle, the GCHandle has already been freed, the retrieval was attempted in the wrong AppDomain, or the GCHandle was marshaled to native code as a GCHandle but passed back into managed code as an IntPtr where a cast was attempted. Attempting to use an invalid pointer to reclaim a GC handle can cause unexpected exceptions, crashes, corruption or data loss.