Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2004

Tip: Looking for answers? Try searching our database.

Marshaling Fixed Length Strings in Structure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom Wells - 26 Jul 2004 22:09 GMT
I trying to pass this structure to a dll:

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
Public Structure udtINTER01
 <VBFixedString(8), MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)>
Public action As Char()
 <VBFixedString(7), MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)>
Public equip_key As Char()
 <VBFixedString(256), MarshalAs(UnmanagedType.ByValArray,
SizeConst:=256)> Public message As Char()
 <VBFixedString(512), MarshalAs(UnmanagedType.ByValArray,
SizeConst:=512)> Public filler As Char()
End Structure

When I pass it to my dll I get this message:

An unhandled exception of type 'System.ArgumentException' occured in
Test1.exe
Additional Information: Type could not be marshaled because the length
of an embedded array instance does not match the declared length in the
layout

I reviewed the length of each element of the structure and they all
matched the declared lengths.

What does it want??

Tom
Brent - 26 Jul 2004 22:13 GMT
I would not worry about the VBFixedString attribute and try

Brent

> I trying to pass this structure to a dll:
>
[quoted text clipped - 24 lines]
>
> Tom
Tom - 27 Jul 2004 00:30 GMT
and try ... ??

and try it without the VBFixedString(?) part?

Tom

> I would not worry about the VBFixedString attribute and try
>
[quoted text clipped - 28 lines]
>>
>>Tom
Tom Wells - 27 Jul 2004 13:46 GMT
Tried it. Doesn't make any difference. I still get the same result.
What does it want?

Tom

> I would not worry about the VBFixedString attribute and try
>
[quoted text clipped - 28 lines]
>>
>>Tom

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.