[Mono-bugs] [Bug 77523][Nor] Changed - PtrToStructure(IntPtr, object) should throw exception if object is not formatted class

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Feb 10 11:45:16 EST 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 kornelpal at hotmail.com.


--- shadow/77523	2006-02-10 11:02:22.000000000 -0500
+++ shadow/77523.tmp.30586	2006-02-10 11:45:15.000000000 -0500
@@ -54,6 +54,21 @@
 ------- Additional Comments From jonathan.chambers at ansys.com  2006-02-10 11:02 -------
 Actually, LOGFONTA/LOGFONTW should be a formatted class, not a struct.
 Here is an MSDN article about using ToLogFont.
+------- Additional Comments From kornelpal at hotmail.com  2006-02-10 11:45 -------
+Note that structures are boxed when casting to object, so they are 
+copied rather than passed by reference. This causes the above MSDN 
+sample code to fail. But if you save the boxed object prior to 
+passing to ToLogFont you can use the modified structure as well:
+object log1 = new LOGFONT();
+LOGFONT log2;
+log2 = (LOGFONT)log1;
+Thus PtrToStructure can and should work with structures because it 
+expects an object so it will get a boxed structure that can be 

More information about the mono-bugs mailing list