我试图使用以下签名调用Delphi DLL中的方法:
function SMap4Ovr(const OverFileName : ShortString ;
const Aclay : Integer ;
const Acarbon : Double ;
out errstr : ShortString): WordBool;
Run Code Online (Sandbox Code Playgroud)
我在C#中使用以下导入:
[DllImport("SMap.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern bool SMap4Ovr(
string OverFileName,
int Aclay,
double Acarbon,
out string errstr
);
Run Code Online (Sandbox Code Playgroud)
但我得到一个AccessViolationException.
我似乎能够调用DLL中的几个更简单的方法,这些方法有字符串参数但不是int或double.
我也试过CallingConvention = CallingConvention.Cdecl,但这给了我同样的错误.