Problem with Marshal.StructureToPtr CF 2.0

  • Thread starter Thread starter Enrico Pavesi
  • Start date Start date
E

Enrico Pavesi

I'm tring to port XrossOne GDI+ to cf 2.0

Using the fontX class i have a strange exception (NotSupported) on Marshal .

GdiLogFont lf = new GdiLogFont();

lf.CharSet = (byte)GdiFontCharset.Default;

lf.ClipPrecision = 0;

.........

IntPtr pLF = GdiHelper.LocalAlloc(0x40, 92);

Marshal.StructureToPtr(lf, pLF, false); <------ Not Supported exception



Does it have something different than CF 1.0?

Thanks
 
I have tried on emulators and a real device same result.

Solution with CF 1.o sp3 works
CF 2 give me this Not Supported Exception in
Marshal.StructureToPtrInternal.

Im missing something?

Thanks
 
CF 2 is much more picky about how you declare the structure
Could you post your (thier) P/Invoke definition?
 
I found the problem.

I had to modify a string definition in the class to be marshaled correctly.

Thanks
 
Alex is correct, in v2 StructureToPtr will attempt to deep marshal the
entire structure and will encounter more problems if the structure has
fields we don't know how to marshal. However, you should be able to get
the v1 behavior by "coercing" the application (although fixing the
structure to be marshal-able is probably the better approach...):

http://blogs.msdn.com/stevenpr/search.aspx?q=coercion&p=1

Ryan Chapman
..NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top