Electronic Engineer Discuss

View: 5984|Reply: 3
Print Prev. thread Next thread

关于C#二次开发6204BC的问题,调用GetData报内存受保护huo'sun'...

[Copy link]

2

Threads

2

Posts

2

Credits

新手上路

Rank: 1

Credits
2
Jump to specified page
1#
Post time 2020-7-9 14:18:09 | Show all posts Reply Awards |Descending |Read mode
Edited by Stillwater at 2020-7-9 14:20

我在用C#二次开发时遇到调用HTHardDll.dll中的dsoHTGetData()时发生“ System.AccessViolationException:“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”
”的错误,请问我的代码哪儿有问题吗?谢谢解答

[DllImport(“ HTHardDll.dll”,CharSet = CharSet.Unicode,CallingConvention = CallingConvention.StdCall)]
       p'rivate  unsafe extern short short dsoHTGetData(short nDeviceIndex,short * pCH1Data,short * pCH2Data,short * pCH3Data,short * pCH4Data,ControlData pControl);
        private static bool GetData(index,out short [] bufferCH1,out short [] bufferCH2,out short [] bufferCH3,out short [] bufferCH4,ControlData pControl)
        {
            bool readSuccess = false;
            bufferCH1 =new short [pControl.nReadDataLen];
            bufferCH2 =new short [pControl.nReadDataLen];
            bufferCH3 =new short [pControl.nReadDataLen];
            bufferCH4 =new short [pControl.nReadDataLen];
            unsafe
            {
                 fiexd(short * pBufferCH1 = bufferCH1)
                 fiexd(short * pBufferCH2 = bufferCH2)
                 fiexd(short * pBufferCH3 = bufferCH3)
                 fiexd(short * pBufferCH4 = bufferCH4)
                    readSuccess = dsoHTGetData(index,pBufferCH1,pBufferCH2,pBufferCH3,pBufferCH4,pControl)!= 0;此处发生“AccessViolationException:“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”错误
            }
             return readSuccess;
        }



This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|Electronic Engineer Discuss

2024-5-3 02:36 GMT+8 , Processed in 0.218285 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

Quick Reply To Top Return to the list