Re: Structure in CSharp




[FieldOffset(4)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 25)]
public byte LocalPhoneNumber;
};

This for some reason is not working for LocalPhoneNumber field in the above
structure. It gives runtime error which is as below:

Cannot marshal field 'MyStruct' of type 'R_OMNI_LINK_MESSAGE': The type
definition of this field has layout information but has an invalid
managed/unmanaged type combination or is unmarshalable.


You can only use ByvalArray on actual array types. So the type of
LocalPhoneNumber should be byte[].


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.