G
Guest
Hi
I have a problem with calling a native library from C# on PocketPC 2003. I want to call a function that has a pointer to a structure as parameter. The structure itself has this form
struct sockaddr
u_short sa_family
char sa_data[14]
}
The signature of the function to call is
int rtBind (uint s, struct sockaddr *addr, int namelen)
I used DllImport to import the function
[DllImport("rt_api.dll")
static extern int rtBind(uint s, ref sockaddr name, int namelen)
I created a struct to represent the structure
public struct sockadd
public ushort sa_family;
public byte[] sa_data;
Then I call the function with
uint newsock
...
sockaddr name
name.sa_family = 0
name.sa_data = new byte[14]
int result = rtBind(newsock, ref name, System.Runtime.InteropServices.Marshal.SizeOf(name))
This results in a NotSupportedException at runtime
How can I do this call to a function in C# and the .NET CompactFramework
Thanks for your help
Kind regards
Dominik Haneber
I have a problem with calling a native library from C# on PocketPC 2003. I want to call a function that has a pointer to a structure as parameter. The structure itself has this form
struct sockaddr
u_short sa_family
char sa_data[14]
}
The signature of the function to call is
int rtBind (uint s, struct sockaddr *addr, int namelen)
I used DllImport to import the function
[DllImport("rt_api.dll")
static extern int rtBind(uint s, ref sockaddr name, int namelen)
I created a struct to represent the structure
public struct sockadd
public ushort sa_family;
public byte[] sa_data;
Then I call the function with
uint newsock
...
sockaddr name
name.sa_family = 0
name.sa_data = new byte[14]
int result = rtBind(newsock, ref name, System.Runtime.InteropServices.Marshal.SizeOf(name))
This results in a NotSupportedException at runtime
How can I do this call to a function in C# and the .NET CompactFramework
Thanks for your help
Kind regards
Dominik Haneber