Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
System.AccessViolationException dll C#HANTEK SDK_C#_C++ - Fatal编程技术网

System.AccessViolationException dll C#HANTEK SDK

System.AccessViolationException dll C#HANTEK SDK,c#,c++,C#,C++,来自Hantek sdk的C++ HTMARCH_API short WINAPI dsoReadHardData(WORD DeviceIndex, short* pCH1Data, short* pCH2Data, ULONG nReadLen,

来自Hantek sdk的C++

HTMARCH_API short WINAPI dsoReadHardData(WORD DeviceIndex,
                                         short* pCH1Data, 
                                         short* pCH2Data, 
                                         ULONG nReadLen,
                                         short* pCalLevel,
                                         int nCH1VoltDIV,
                                         int nCH2VoltDIV,
                                         short nTrigSweep,
                                         short nTrigSrc,
                                         short nTrigLevel,
                                         short nSlope,
                                         int nTimeDIV,
                                         short nHTrigPos,
                                         ULONG nDisLen,
                                         ULONG* nTrigPoint, 
                                         short nInsertMode);
#

使用

怎么了? 当程序停止pCH1Data和pCH2Data中的所有数据时。
尝试写入包装器,但有错误的零值

C声明和DLLImport语句中的第五个参数是作为指向short/short数组的指针键入的,但是在调用函数时传递的第五个参数名为
m_nCalData
,这意味着一个整数值。确保传递一个short数组作为第五个参数。

参数nTrigPoint是指向无符号long的指针,您已将其重新声明为无符号整数,它需要是指针,并且需要为其提供无符号long的地址,因为DLL函数将设置nTrigPoint指向的任何对象,到触发点索引(相对于原始数据数组)


参数pCalLevel必须是大小为32的短数组的地址,只需将其memset设置为0,或者先用dsoGetCalLevel()填充即可。

在我看来,我面临的问题与您相同。。。你找到解决问题的方法了吗?
 [DllImport("HTMarch.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.StdCall)] 
 public static extern  short  dsoReadHardData(short DeviceIndex,
                                              short[] pCH1Data,
                                              short[] pCH2Data, 
                                              uint nReadLen,
                                              short[] pCalLevel,
                                              int nCH1VoltDIV,
                                              int nCH2VoltDIV,
                                              short nTrigSweep,
                                              short nTrigSrc,
                                              short nTrigLevel,
                                              short nSlope,
                                              int nTimeDIV,
                                              short nHTrigPos,
                                              uint nDisLen,
                                              uint nTrigPoint,
                                              short nInsertMode);
int nReadLen = 10240;//10k
            int nDrawLen = 10000;
            short nTrigLevel = 64;
            short nSlope = 0;// 0:Rise; 1: Fall
            short nHTrigPos = 50;// 0 ~ 100
            uint  nTrigPoint = 0;
            short[] pCH1Data = new short[nReadLen];
            short[] pCH2Data = new short[nReadLen];
            short nRe = Hantek.dsoReadHardData(m_nDevIndex,
                                        pCH1Data,
                                        pCH2Data,
                                        (uint)nReadLen,
                                        m_nCalData,
                                        m_nCH1VoltDIV,
                                        m_nCH2VoltDIV,
                                        0,//0:AUOT; 1:Normal; 2: Signal
                                        0,//CH1
                                         nTrigLevel,
                                        nSlope,
                                        m_nTimeDIV,
                                        nHTrigPos,
                                        (uint)nDrawLen,
                                        nTrigPoint,
                                        0);