Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dll and structures
Message
 
À
11/07/2003 13:09:47
Vicki Miles
Vlm International, Inc.
Mishawaka, Indiana, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00809272
Message ID:
00809389
Vues:
22
>I am new to C# programming and trying to convert a sample C program into C#.
>
>I'm successfully calling the first Dll call. But the second Dll call is using two structures and results in a MarshallDirectiveException (Method's type signature is not PInvoke compatible) error.
>


Just some misc. rambling, I'm not sure any of this will be of much help. But maybe it'll at least point you in the right direction.

When I played with PInvoke a while back I noticed things got "not so obvious" as soon as you needed to pass pointers around (eg. string *myStringPtr defines a pointer to a string named myStringPtr). Pointers are basically "ref" or "ByRef" (in VB) types. From what I found then, you can pass a char * out by using the StringBuilder class instead:
char *myStringPtr;
becomes
StringBuilder myStringPtr;
I have no idea if PInvoke will allow/marshall that inside of a structure, though.

Any lines like:
short int myIntValue;
become:
short myIntValue;
I don't know how you'd define an array of "short" inside of a structure that PInvoke can handle, though. Maybe a normal array might work:
short[] myShortInt = new short[10];
Or Maybe something in the in the Marshalling class?

System.Runtime.InteropServices.Marshal
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform