MarshalAs(UnmanagedType. EXception

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have DLL (unmannaged code) , in this DLL I have some functions and
structures.
one of those functions is GetDataBaseStructure (GDS_Structure *str), the
structure definition is as following :

//// GDS - General Data Structure
typedef struct _T_GeneralTestsDatabase {
int argc;
char *argv[256];//*argv[]
int numberOfStructure; //number of structurs
LPVOID ArrayOfStructurs;//handle array of GDS or TS
} GDS_Structure;


I tring to define such a structure in C# but without succsseed:

[ StructLayout( LayoutKind.Sequential )]
public struct GENERAL_DATABASE_structure //GDS
{
public int argc;

// I G O T Error H E R E
[MarshalAs(UnmanagedType.LPStr, SizeConst=256 )]
public StringBuilder [] argv;//*argv[]

public int numberOfStructure;
// I G O T Error H E R E
[ MarshalAs(UnmanagedType.LPStruct)]
unsafe public void* ArrayOfStructurs;
}

I get an exception when try to execute the function :
GetDataBaseStructure (ref my_GENERAL_DATABASE_structure);

what is wrong how can I define such an unmanaged code in C# ?

.



Relevant Pages