C# .net and DrDaq

Post your .Net discussions here
Post Reply
Hads
Newbie
Posts: 0
Joined: Tue Dec 01, 2015 5:24 am

C# .net and DrDaq

Post by Hads »

Hi,

I am having trouble getting the scalings with a memory corruption error, I am a little rusty with C, would someone be able to give me an idea what may be the cause?

Code: Select all

{
                using(DrDaqManager mgr = new DrDaqManager())
                {
                    short nScales = 0;
                    short currentScales = 0;
                    char[] names = new char[1000];
                    mgr.GetScalings(USBDrDaqWrapper.enUsbDrDaqInputs.USB_DRDAQ_CHANNEL_EXT1, out nScales, out currentScales, out names, 1000);
                }
            }
            catch(Exception ex)
            {

            }

Code: Select all

        public USBDrDaqWrapper.PICO_STATUS GetScalings(USBDrDaqWrapper.enUsbDrDaqInputs channel, out short nScales, out short currentScale, out char[] names, short namesSize)
        {
            return (USBDrDaqWrapper.PICO_STATUS)USBDrDaqWrapper.UsbDrDaqGetScalings(UnitId, (int)channel, out nScales, out currentScale, out names, namesSize);
        }
An unhandled exception of type 'System.AccessViolationException' occurred in DrDaqBatteryTester.exe

Hitesh

Re: C# .net and DrDaq

Post by Hitesh »

Hi Hads,

How are you defining the call to the driver using DllImports?

Try passing the 'names' array without the out keyword.

Regards,

Post Reply