c#调用c++ api函数之参数类型问题-急(高人教教我)
c#调用c++ api函数之参数类型问题
c++函数定义如下
extern "C"
{
struct colorstruct
{
double dbValueInterval;
CString str;
IColorPtr ipColor;
colorstruct()
{
str = _T(" ");
dbValueInterval = 0.0;
ipColor.CreateInstance(CLSID_RgbColor);
}
};
__declspec(dllexport) void CressmantestforSK (int a,int irad,float * rads,int isiz,int jsiz,float dbCellSize,double lnmin,double lnmax,double ltmin,double ltmax,long stnnum,float *stnlon,float *stnlat,float *stnrpt,float *grid,colorstruct *colorArray,int iLineNum,float NoDefineVale);
}
C#中extern 如下
[DllImport("CressmanforSk24.dll")]
public extern static void CressmantestforSK( //__declspec(dllexport) void CressmantestforSK (
int a, // int a,
int irad, // int irad,
Single[] rads, // Single * rads,
int isiz, // int isiz,
int jsiz, // int jsiz,
Single dbCellSize, // Single dbCellSize,
double lnmin, // double lnmin,
double lnmax, // double lnmax,
double ltmin, // double ltmin,
double ltmax, // double ltmax,
long stnnum, // long stnnum,
Single[] stnlon, // Single *stnlon,
Single[] stnlat, // Single *stnlat,
Single[] stnrpt, // Single *stnrpt,
out Single[] grid, // Single *grid,
colorstruct[] colorArray, // colorstruct *colorArray,
int iLineNum, // int iLineNum,
Single NoDefineVale // Single NoDefineVale
); // );
public struct colorstruct
{
/// <summary>
/// 数值
/// </summary>
[MarshalAs(UnmanagedType.R8)]
public double dbValueInterval;// = 0;
/// <summary>
/// 名称
/// </summary>
[MarshalAs(UnmanagedType.LPStr)]
public string str;// = " "
/// <summary>
/// 颜色
/// </summary>
[MarshalAs(UnmanagedType.Interface)]
public IColor ipColor;// = new RgbColorClass()
//void colorstruct()
//{
// str = _T(" ");
// dbValueInterval = 0.0;
// ipColor.CreateInstance(CLSID_RgbColor);
//}
};
报错 :尝试读取或写入受保护的内存,内存已损坏
初步确定是参数类型对应的问题,谁能帮帮我啊
msn:jpu_jacky@eyou.com