我正在尝试调用一个具有以下签名的Delphi DLL中的方法:
function SMap4Ovr(const OverFileName : ShortString ;
const Aclay : Integer ;
const Acarbon : Double ;
out errstr : ShortString): WordBool;
我正在使用C#中的以下导入:
[DllImport("SMap.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern bool SMap4Ovr(
string OverFileName,
int Aclay,
double Acarbon,
out string errstr
);
但我收到了AccessViolationException异常。
我似乎可以调用DLL中一些具有字符串参数的较简单的方法,但不能调用具有整数或双精度参数的方法。
我还尝试了使用CallingConvention = CallingConvention.Cdecl,但这仍然导致相同的错误。