I'm trying to serialize my struct and I need to convert IntPtr to byte array. Here's an example:
//IntPtr hWnd = this.Handle;
int size = Marshal.SizeOf(typeof(IntPtr));
byte[] managedArray = new byte[size];
Marshal.Copy(hWnd, managedArray, 0, size); //Exception: AccessViolationException
Why?