Test and Measurement Forum

Problem with calling usbpt104.dll from managed C#

Post your .Net discussions here

Problem with calling usbpt104.dll from managed C#

Postby Xandolph » Thu Apr 02, 2015 9:34 am


I'm writing a wrapper in C# for the usbpt104.dll.
I can open the device via ethernet, set channels, read data and close the device without any problems.
But I'm still having a problem with the UsbPt104GetUnitInfo method. It keeps throwing a PInvokeStackImbalance.
Here's my import:
Code: Select all
[DllImport("UsbPT104.dll", SetLastError = true)]
private static extern PICO_STATUS UsbPt104GetUnitInfo(short handle, String information, int stringLength, ref int requiredSize, long info);

That's how i call the method:
Code: Select all
String info = "";
int requiredSize = 0;
PICO_STATUS status = UsbPt104GetUnitInfo(handle, info, 255, ref requiredSize, 4);

What am I doing wrong?
Thanks for your help!
Posts: 0
Joined: Thu Apr 02, 2015 9:20 am

Re: Problem with calling usbpt104.dll from managed C#

Postby Hitesh » Thu Apr 02, 2015 3:22 pm

Hi Xandolph,

Try using the StringBuilder class instead of a String.

Also check the data types for the requiredSize and info parameters.

You can find examples of defining similar functions in our oscilloscope SDK C# examples e.g. for the PicoScope 3204D.


Technical Support Engineer
Site Admin
Site Admin
Posts: 2749
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