一般来说,C#调用C++生产的dll,如下:
C++的项目要设置为"导出dll的项目",而且导出的函数,一般为:
extern "C" __declspec(dllexport) int Convrnx(int format, rnxopt_t opt, char *file, char **ofile){
....}
弄出一个C++的dll后,放到C#的生成目录下,也就是和.exe放在一起;
而C#,则要:
[DllImport("RtklibHelper.dll", EntryPoint = "Convrnx", CallingConvention = CallingConvention.Cdecl)]public static extern int Convrnx(int format, rnxopt_t opt, string file, string[] ofile){
....}
坑一:C#的类型,怎么和C++的类型对应起来(如例子:string对应*char,string[]对应char**)
解一:有一款神奇的工具,名为:CLRInsideOut,微软的手笔: