Microsoft
Software
Hardware
Network
Question : exception with dllimport
Hello experts
I am having problems with importing a unmanaged dll,
I am getting an exception when trying to run a function that receives a struct (DB_Client).
this is the code,
I am using c# WinForm VS2005
Thanks.
c++ dll :
typedef char FieldStr[256];
typedef char FieldTime[20];
struct DB_Client
{
unsigned long client_id;
unsigned long parent_id;
FieldStr mask_name;
FieldStr comp_name;
FieldStr comp_type;
FieldStr ip;
FieldStr login_name;
FieldStr rdxrc_addr;
FieldStr net_name;
FieldStr os;
FieldTime diff_time;
FieldStr mac_address;
FieldTime handshake_time;
unsigned int is_online;
};
bool DB_get_client(unsigned long client_id, DB_Client& client_obj);
//////////////////////////
//////////
//
c# app
public struct DB_Client
{
public ulong client_id;
public ulong parent_id;
public string mask_name;
public string comp_name;
public string comp_type;
public string ip;
public string login_name;
public string rdxrc_addr;
public string net_name;
public string os;
public string diff_time;
public string mac_address;
public string handshake_time;
public uint is_online;
};
[DllImport("rdxDB.dll")]
public static extern bool DB_get_client(ulong client_id,DB_Client client_obj);
private void form1_Load(object sender, EventArgs e)
{
DB_Client dbcl = new DB_Client();
DBDll.DB_get_client(14,dbc
l);
}
exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Answer : exception with dllimport
Did you change the method to use 'ref'
And you've got a long in there - so the C# version needs to have an int instead...
Random Solutions
How can I limit Remote Desktop connections to the Administrator account only?
Microsoft, Exchange, 2000, Active Directory / DNS, Process MAD.EXE (PID=1324). All Domain Controller Servers in use are not responding:
TRANSPARENT BACKGROUND color at RMagick does not work properly
total of user accounts in active directory
Need information on Long Integer, Integer, Byte, Single, Double, Replication ID, etc.
need a step by step on how to setup Reverse DNS for Exchange mail server.
Email Button In Access
Best mini linux 1u or box?
fetchrow_array() no print
DBase IV and Unexpected Error