Test and Measurement Forum

C# .net and DrDaq

Post your .Net discussions here

C# .net and DrDaq

Postby Hads » Tue Dec 01, 2015 5:30 am

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
Hads
Newbie
 
Posts: 0
Joined: Tue Dec 01, 2015 5:24 am

Re: C# .net and DrDaq

Postby Hitesh » Fri Dec 04, 2015 9:34 am

Hi Hads,

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

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

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2007
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests