C#
一种面向对象的类型安全的编程语言,它起源于 C 语言系列,包括对面向组件的编程的支持。
184 个问题
我在我的 C# 程序中调用了 CPPDLL。以下是我的 C# 代码片段:
**public struct ImageData
{
public int imageSize;
public byte[] image;
}
public struct CppImportInfo
{
public byte[] name { get; set; }
public byte[] id;
public int group;
public byte[] company;
public byte[] e_mail;
public byte[] title;
public byte[] note;
public ImageData imageData;
};
class CDllWrapper
{
#region Dll interface
public CDllWrapper() { }
[DllImport("FRV_Dll", //name of the dll
EntryPoint = "Face_Register", //name of function in dll
ExactSpelling = true,
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
......
}**
以下是我在 CPP DLL 上的代码片段:
**struct ImageData
{
int imageSize;
unsigned char* image;
};
struct ImportInfo
{
char* name;
.......
char* note;
struct ImageData imageData;
};
//ensure naked export
extern "C"
{
......
CPLUSPLUS_API int Face_Register(struct ImportInfo *imageData, int* retCode, char** retMessage);
...
}**
当我检查imageInfo->imageData.image时,我发现它是错误的。怎么会这样?
Note:此问题总结整理于: Data structure of parameters from C# calling CPP DLL