期間我有這樣的DLL調用:AccessViolation的PInvoke
[DllImport("FreqCntPcIntf.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Intf_ErrorType FreqCntIntf_Init(
ref byte InstNo,
string InstName,
string PortServerName,
ulong UartComPort,
ulong MaxBlockTime);
enum Intf_ErrorType
{
...
}
而C++的聲明是這樣的:
FREQCNTINTF_API Intf_ErrorType STDCALL FreqCntIntf_Init(InstanceNoType* InstNo, const char* InstName, const char* PortServerName, rsuint32 UartComPort, rsuint32 MaxBlockTime);
其中:
typedef enum
{
....
} RSENUM8(Intf_ErrorType);
#define FREQCNTINTF_API __declspec(dllexport)
typedef rsuint8 InstanceNoType;
typedef unsigned char rsuint8;
#define RSENUM32(EnumName) Enum_##EnumName; typedef rsuint32 EnumName
我通話過程中收到AccessViolation。我應該在哪裏尋找錯誤?
ULONG在C#爲8字節寬,而不是4個字節 – 2012-02-06 14:41:38