2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / System.Runtime.InteropServices / GCHandle.cs
index ace8f6a64fbcac41151d40cc5fc63a61285567c1..ec5f1e1980a5b7e1cc2fa01ceb6c1fa7207cc835 100755 (executable)
@@ -64,7 +64,7 @@ namespace System.Runtime.InteropServices
                { 
                        get
                        {
-                               return (handle != 0);
+                               return (handle != -1);
                        }
                }
 
@@ -86,6 +86,8 @@ namespace System.Runtime.InteropServices
                        IntPtr res = GetAddrOfPinnedObject(handle);
                        if (res == IntPtr.Zero)
                                throw new InvalidOperationException("The handle is not of Pinned type");
+                       if (res == (IntPtr)(-1))
+                               throw new ArgumentException ("Object contains non-primitive or non-blittable data.");
                        return res;
                }
 
@@ -102,7 +104,7 @@ namespace System.Runtime.InteropServices
                public void Free()
                {
                        FreeHandle(handle);
-                       handle = 0;
+                       handle = -1;
                }
                
                public static explicit operator IntPtr (GCHandle value)