[Mono-dev] Issues with StructureToPtr- and PtrToStructure-wrapper building

Robert Jordan robertj at gmx.net
Tue Feb 8 05:31:23 EST 2011

On 08.02.2011 10:51, Martin Däumler wrote:
> When trying to adopt the pre-compilation routine to the mscorlib,
> some classes cause a SIGABRT. For example, 'System.MonoEnumInfo',
> 'System.Configuration.Assemblies.AssemblyHash' or 'ProcessMessageRes'
> do not work. The stacktrace is always as follows:
> ** ERROR **: Structure field of type Byte[] can't be marshalled as LPArray
> aborting...

Not all structs or classes marked with
[StructLayout(LayoutKind.Sequential)] are actually "blittable"
(as in suitable for p/invoke marshaling).

When you look at System.MonoEnumInfo you'll see that
it contains non-blittable fields.

> So, my question is: Which classes and structs allow the generation
> of StructureToPtr- and PtrToStructure-wrappers at all and how to
> determine these?

You may want to check the MonoClass.blittable field before
compiling a wrapper for a given type, but I'm sure it's enough.


More information about the Mono-devel-list mailing list