我只是在 c# 中导入了一个非托管的 c++ dll
[DllImport("OPT.DLL", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?optimise@@YAHPAH0000000PAN10011011100001110100001111HHPAD@Z", CharSet = CharSet.Ansi)]
该函数如下所示:
Public static extern unsafe int optimise(int* m, int* n, int* nb, int* ne,
int* nncon, int* nnobj, int* nnjac,
int* iobj, double* objadd,
double* a, int* ha, int* ka, double* bl, double* bu,
int* hs, double* xn, double* pi, double* rc,
int* inform, int* mincor, int* ns, int* ninf, double* sinf, double* obj,
double* z, int* nwcore, double* q, int* nq,
int* komp, int* qsorte, int* sorte, double* vecSorte, double* vecKomp, double* matrixFrac, double* c, int lss, int lsk, byte* OkFile);
我的问题是,当我使用此函数时,它会引发 IndexOutOfRange 异常。怎么会这样?我不使用任何 Array 或类似的功能。我以通常的方式使用它:
int h
h = optimise(...);
感谢您的帮助!