Re: Structure in CSharp
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Thu, 10 May 2007 06:36:36 +0200
[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.
.
- References:
- Re: Structure in CSharp
- From: Peter Duniho
- Re: Structure in CSharp
- From: Yatin Patel
- Re: Structure in CSharp
- Prev by Date: Re: Event Viewer Logging - Add a new overall type
- Next by Date: Re: Structure in CSharp
- Previous by thread: Re: Structure in CSharp
- Next by thread: Re: Structure in CSharp
- Index(es):