J
jonpb
Hi,
I would like to pass an array of formatted blittable classes through
P/Invoke to a C++ dll, but it is not working. Here are the definitions:
C++
struct Point2Rec
{
double x;
double y;
};
void WINAPI AddPolyToList(Point2Rec* pg1, int numPts);
C#
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public class Point2D
{
private double _x;
private double _y;
public double X { get { return _x; } set { _x = value; } }
public double Y { get { return _y; } set { _y = value; } }
}
[DllImport("ascBool.dll")]
public static extern void AddPolyToList([In, Out] Point2D[] pg1, int
numPts);
If I change "class" to "struct" it works. I am taking my information
from the following documentation:
http://msdn2.microsoft.com/en-us/library/23acw07k(VS.80).aspx
Is there something I'm missing in the definitions of formatted and
blittable, or is it just not possible to pass an array of formatted
blittable classes to a C++ dll.
Thanks
I would like to pass an array of formatted blittable classes through
P/Invoke to a C++ dll, but it is not working. Here are the definitions:
C++
struct Point2Rec
{
double x;
double y;
};
void WINAPI AddPolyToList(Point2Rec* pg1, int numPts);
C#
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public class Point2D
{
private double _x;
private double _y;
public double X { get { return _x; } set { _x = value; } }
public double Y { get { return _y; } set { _y = value; } }
}
[DllImport("ascBool.dll")]
public static extern void AddPolyToList([In, Out] Point2D[] pg1, int
numPts);
If I change "class" to "struct" it works. I am taking my information
from the following documentation:
http://msdn2.microsoft.com/en-us/library/23acw07k(VS.80).aspx
Is there something I'm missing in the definitions of formatted and
blittable, or is it just not possible to pass an array of formatted
blittable classes to a C++ dll.
Thanks