Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dll and structures
Message
From
11/07/2003 13:09:47
Vicki Miles
Vlm International, Inc.
Mishawaka, Indiana, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Dll and structures
Miscellaneous
Thread ID:
00809272
Message ID:
00809272
Views:
58
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.

The successful call is
LibWrapper.taxStart();
The unsuccessful call that results in the above error is
tt=LibWrapper.taxInit(tax_log,open_db,cache_size,fp,session_hdl);
where
short tax_log = 0;
short open_db = 0;
int cache_size = 4800;
file_path fp = new file_path();
long session_hdl = 1;
taxes_tbl tt;
The LibWrapper class is as follow:
class LibWrapper
{
	[DllImport("tax.dll")]
	public static extern void taxStart(); 
	[DllImport("tax.dll")]
	public static extern taxes_tbl taxInit(short tax_log, short open_db, int cache_size, file_path paths, long session_hdl);
The structures of taxes_tbl and file_paths in the original c is as follows:
struct taxes_tbl
{
	unsigned long int	j_code;
	short int		tax_type;
	short int		tax_level;
	short int		calc_type;
	float			rate;
	double			tax_amount;
	char			*desc;
	short int		TVcalc_type_id;
	short int		TVsurcharge;
	short int		TVtax_type_id[10];
	short int		TVtax_level_id[10];
};

struct file_path
{
	char		*Tax_data;
	char		*Tax_IDX;
	char		*Tax_DLL;
	char		*Tax_log;
	char		*Tax_npanxx;
	char		*Tax_status;
	char		*Tax_temp_file;
	char		*Tax_location;
	char		*Tax_zip;
	char		*Tax_customer_key;
	char		*Tax_pcode;
	char		*Tax_jcode;
	char		*Tax_over;
};
The c# compiler specifically complains about the "*" character in front of the structure members and the "[10]". I have removed both of these in my test. So I would guess that this is what is causing the error I get. But I don't know how to appropriately configure them. Any help would be appreciated.

Thanks.
Next
Reply
Map
View

Click here to load this message in the networking platform