?
=?ISO-8859-1?Q?Carlos_Guzm=E1n_=C1lvarez?=
Hello:
I'm trying to execute a function of a unmanaged dll using PInvoke, i
have definied the function as:
[DllImport(FbClient.DllPath)]
public static extern int isc_dsql_prepare(
int[] status_vector,
ref int trans_handle,
ref int stmt_handle,
short length,
string statement,
short dialect,
ref XSQLDA xsqlda);
the XSQLDA structure is defined as:
[StructLayout(LayoutKind.Sequential)]
public struct XSQLDA
{
public short version;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=8)]
public string sqldaid;
public int sqldabc;
public short sqln;
public short sqld;
public XSQLVAR[] sqlvar;
}
[StructLayout(LayoutKind.Sequential)]
public struct XSQLVAR
{
public short sqlType;
public short sqlScale;
public short sqlSubType;
public short sqlLen;
public byte[] sqlData;
public short sqlInd;
public short sqlNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string sqlName;
public short relNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string relName;
public short ownerNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string ownerName;
public short aliasNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string aliasName;
}
But i get always a TypeLoadException when i exec it, the problem seems
to be with :
public XSQLVAR[] sqlvar;
Removing this line i can execute the function but i need it
Any idea on how to solve this ??
Thanks in advance
I'm trying to execute a function of a unmanaged dll using PInvoke, i
have definied the function as:
[DllImport(FbClient.DllPath)]
public static extern int isc_dsql_prepare(
int[] status_vector,
ref int trans_handle,
ref int stmt_handle,
short length,
string statement,
short dialect,
ref XSQLDA xsqlda);
the XSQLDA structure is defined as:
[StructLayout(LayoutKind.Sequential)]
public struct XSQLDA
{
public short version;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=8)]
public string sqldaid;
public int sqldabc;
public short sqln;
public short sqld;
public XSQLVAR[] sqlvar;
}
[StructLayout(LayoutKind.Sequential)]
public struct XSQLVAR
{
public short sqlType;
public short sqlScale;
public short sqlSubType;
public short sqlLen;
public byte[] sqlData;
public short sqlInd;
public short sqlNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string sqlName;
public short relNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string relName;
public short ownerNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string ownerName;
public short aliasNameLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string aliasName;
}
But i get always a TypeLoadException when i exec it, the problem seems
to be with :
public XSQLVAR[] sqlvar;
Removing this line i can execute the function but i need it

Any idea on how to solve this ??
Thanks in advance