G
Guest
Hi All, I Have A Few Problems with a unmanged DLL (VC6) sending back data to
a C# application. The DLL is passed 10 "strings" (char* in the dll), which
should then be updated - in other words i want to pass some strings to the
dll by reference - it is called like this
s1 = enc.GetBytes(lat);
s2 = enc.GetBytes(lon);
s3 = enc.GetBytes(Sats);
s4 = enc.GetBytes(height);
s5 = enc.GetBytes(pDop);
s6 = enc.GetBytes(fp6);
s7 = enc.GetBytes(fp7);
s8 = enc.GetBytes(fp8);
s9 = enc.GetBytes(fp9);
s10 = enc.GetBytes(fp10);
MMGPS.PNT1_TO_AV(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
lat = enc.GetString(s1);
lon = enc.GetString(s2);
Sats = enc.GetString(s5);
height = enc.GetString(s3);
pDop= enc.GetString(s4);
fp6 = enc.GetString(s6);
fp7 = enc.GetString(s7);
fp8 = enc.GetString(s8);
fp9 = enc.GetString(s9);
fp10 = enc.GetString(s10);
The Dll Code get the striings okay, proceeds with the processing and updats
them in the dll with the returned version. But when the data gets brought
back to the calling program, it appears that the C# code is only picked up
the first char of the string: so instead of getting 190311.11, it gets 1, and
instead of 44.898 it will get 4, does anybody have any suggestions about what
is cxausing this?
Andrew.
PS here are the C++ and C# function declatations.
int _stdcall PNT1_TO_AV(char* fp1, char* fp2, char* fp3, char* fp4, char*
fp5, char* fp6,
char* fp7, char* fp8, char* fp9, char* fp10)
{
}
[DllImport("MMGPS", EntryPoint = "PNT1_TO_AV", ExactSpelling = true, CharSet
= CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void PNT1_TO_AV(
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp1,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp2,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp3,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp4,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp5,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp6,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp7,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp8,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp9,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp10);
a C# application. The DLL is passed 10 "strings" (char* in the dll), which
should then be updated - in other words i want to pass some strings to the
dll by reference - it is called like this
s1 = enc.GetBytes(lat);
s2 = enc.GetBytes(lon);
s3 = enc.GetBytes(Sats);
s4 = enc.GetBytes(height);
s5 = enc.GetBytes(pDop);
s6 = enc.GetBytes(fp6);
s7 = enc.GetBytes(fp7);
s8 = enc.GetBytes(fp8);
s9 = enc.GetBytes(fp9);
s10 = enc.GetBytes(fp10);
MMGPS.PNT1_TO_AV(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
lat = enc.GetString(s1);
lon = enc.GetString(s2);
Sats = enc.GetString(s5);
height = enc.GetString(s3);
pDop= enc.GetString(s4);
fp6 = enc.GetString(s6);
fp7 = enc.GetString(s7);
fp8 = enc.GetString(s8);
fp9 = enc.GetString(s9);
fp10 = enc.GetString(s10);
The Dll Code get the striings okay, proceeds with the processing and updats
them in the dll with the returned version. But when the data gets brought
back to the calling program, it appears that the C# code is only picked up
the first char of the string: so instead of getting 190311.11, it gets 1, and
instead of 44.898 it will get 4, does anybody have any suggestions about what
is cxausing this?
Andrew.
PS here are the C++ and C# function declatations.
int _stdcall PNT1_TO_AV(char* fp1, char* fp2, char* fp3, char* fp4, char*
fp5, char* fp6,
char* fp7, char* fp8, char* fp9, char* fp10)
{
}
[DllImport("MMGPS", EntryPoint = "PNT1_TO_AV", ExactSpelling = true, CharSet
= CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void PNT1_TO_AV(
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp1,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp2,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp3,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp4,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp5,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp6,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp7,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp8,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp9,
[MarshalAs(UnmanagedType.LPArray)]
byte[] fp10);