Re: Error on StructureToPtr()
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Thu, 02 Aug 2007 00:34:55 +0200
It fails with: Type could not be marshaled because the length of an embedded
array instance does not match the declared length in the layout.
I compared "len" with the actual size of the structure and it is correct.
Any ideas?
It's the size of the byte array you assign to szDatabase or
szVerification that's incorrect.
Since the members apparently are strings, I'd recommend declaring them
that way to save you some work.
....
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=25)]
public string szDatabase;
public byte cCommand;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string szVerification;
....
pConnectStruct.szDatabase = "MY_DATABASE";
pConnectStruct.szVerification = "ABCDEFGHIJKLMNOP";
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.
- Prev by Date: Re: GetStream.Read behavior changed in .Net 2.0 with respect to ReceiveTimeout
- Next by Date: Re: GetStream.Read behavior changed in .Net 2.0 with respect to ReceiveTimeout
- Previous by thread: Re: Regex help
- Next by thread: Re: Error on StructureToPtr()
- Index(es):