我将Visual Basic 6.0中的函数转换为:
Declare Function RequestOperation Lib "archivedll" (ByVal dth As Long, ByVal searchRequestBuf As String, ByVal buflen As Long, ByVal FieldNum As Long, ByVal OP As Long, ByVal value As String) As Long
在 C# 中,我将函数声明为:
[DllImport("archivedll")]
public static extern int RequestOperation(int dth ,StringBuilder searchRequestBuf, int bufferLen, int fieldNum, int op, string value);
当从 C# 调用 RequestOperation 时,它会抛出一个异常:
[System.AccessViolationException] = {"试图读取或写入受保护的内存。这通常表明其他内存已损坏。"}
我已经成功地调用了许多其他这样的函数,但只有这个函数抛出了异常。