[Mono-bugs] [Bug 79054][Blo] Changed - Unable to cast a ulong to a IntPtr

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Aug 11 07:06:11 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jonpryor at vt.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=79054

--- shadow/79054	2006-08-10 19:37:03.000000000 -0400
+++ shadow/79054.tmp.970	2006-08-11 07:06:11.000000000 -0400
@@ -95,6 +95,23 @@
 If you have any questions, please feel free to drop me a line.
 
 ------- Additional Comments From stephen.gennard at microfocus.com  2006-08-10 19:31 -------
 Created an attachment (id=17439)
 demo
 
+
+------- Additional Comments From jonpryor at vt.edu  2006-08-11 07:06 -------
+The reason this fails on Mono is because System.IntPtr doesn't define
+any conversions from or to ulong -- there is no IntPtr(ulong)
+constructor, for example.
+
+A workaround is to introduce a cast:
+
+    ulong value = ...;
+    IntPtr p = (IntPtr) (long) value;
+
+You could also use (void*) as the intermediate cast.
+
+I would like to know why this works with CSC.EXE, as msdn2 doesn't
+list any IntPtr members that work with the UInt64, so either CSC.EXE
+has an internally-permitted conversion from ulong, or their class
+library has some members which aren't documented.


More information about the mono-bugs mailing list