S
simon.hudson1
Hi All,
I'm writing a C++ dll which takes two parameters, both pointers to
long, modifies them and returns an int (status).
The problem is, as soon as I modify the long parameters I get a native
exception (0xc0000005).
My C++ function is declared as :
int __declspec(dllexport) CMyLib::GetCurrentPos(long* latitude, long*
longitude);
....implemented as:
int CMyLib::GetCurrentPos(long* latitude, long* longitude)
{
*latitude = 0; // test vals
*longitude = 0;
return 0;
}
My C# reference is:
[DllImport("MyLib.dll", EntryPoint = "GetCurrentPos")]
private static extern int GetCurrentPosition(ref int latitude,
ref int longitude);
And the C# call is:
int latitude = 0;
int longitude = 0;
if (GetCurrentPosition(ref latitude, ref longitude) == 0)
{
...
}
I'm pretty sure I'm screwing up the marshalling but I have no idea how.
From the C# end I have tried int, Int32 and long. I've also tried
changing both ends to double, just for the hell of it. In all cases, I
got the same native exception.
Any thoughts, help, advice would be very much appreciated.
Simon
I'm writing a C++ dll which takes two parameters, both pointers to
long, modifies them and returns an int (status).
The problem is, as soon as I modify the long parameters I get a native
exception (0xc0000005).
My C++ function is declared as :
int __declspec(dllexport) CMyLib::GetCurrentPos(long* latitude, long*
longitude);
....implemented as:
int CMyLib::GetCurrentPos(long* latitude, long* longitude)
{
*latitude = 0; // test vals
*longitude = 0;
return 0;
}
My C# reference is:
[DllImport("MyLib.dll", EntryPoint = "GetCurrentPos")]
private static extern int GetCurrentPosition(ref int latitude,
ref int longitude);
And the C# call is:
int latitude = 0;
int longitude = 0;
if (GetCurrentPosition(ref latitude, ref longitude) == 0)
{
...
}
I'm pretty sure I'm screwing up the marshalling but I have no idea how.
From the C# end I have tried int, Int32 and long. I've also tried
changing both ends to double, just for the hell of it. In all cases, I
got the same native exception.
Any thoughts, help, advice would be very much appreciated.
Simon