C#, VB .NET for U12 - Windows | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


C#, VB .NET for U12 - Windows

.NET assembly/wrapper (LJDotNet.dll), and C/C++, C# and VB .NET examples for the LabJack U12. Refer to the README.txt file for further information. 2/16/2017, 30KB.

If you are getting errors like "Unable to load "ljackuw.dll"" when running a U12 .NET application or example, download and run the U12 installer to install the U12 driver.

If you are using any LabJacks in the UD series (U3, UE9, U6) use the UD .NET examples instead.

If you are using any LabJacks in the T series (T7) or the Digit use the LJM .NET examples instead.

File Attachment: 


I am finding it difficult to understand how visual basic software is implemented, can you send me a step by step how to write VB.net software to control the labjack, and explain what each step does?

We do not have a step by step guide beyond the examples, but the following should help get you started:

Refer to the README.txt in the download as it provides details on loading the U12 .Net dll into a project and how to access functions.  The VB examples help with example usage and accessing the functions using VB .NET syntax.  They also provide some comments on what is going on.  In VB, all functions are in the "LabJack" class in the "lj" namespace (lj.LabJack) .  For full documentation on all the labjackuw.dll functions, which the U12 .NET dll provides access to, refer to the Programming Reference section of the User's Guide.

If you run into problems accessing the functions, or have questions that the documentation does not answer we can can help you out further.

could you give me please some more details about the functions and parameters of the functions in the labjack.dll since for example how do i know what should the number of my channel be in order to communicate with a led on the labjack, if you could please send me some more details on the parameters of the .dll functions. and another point i dont know exactley how to connect a led with its transistor into a labjack, so if you could please let me know how we could do so using pictures as a demonstrative type if possible. 


thx a lot

I replied to your other other comment on LED connections and a couple of functions to use.  I don't believe we have a picture of a LED connected to a U12, but we do have one for a U3 which has the LED's cathode and anode connected to a ground (GND) and digital I/O (FIO4) screw terminal that may be helpful:


For all functions and parameters documentation in the U12 driver (ljackuw.dll) refer to Section 4 of the User's Guide:


It should state here how to specify channels in the function you want to use.

i am new for labjack and c# programming, i want to connect a led to the labjack u12 by using its 30 screws, and control that led from a c# program. so i just want to turn that led on and off from a c# program, can you tell me please how to exactley do that? and where to connect that led exactley. thx again

One way to connect your LED would be connect the cathode of the LED to a ground (GND) screw terminal and the anode of the LED to a digital I/O screw terminal (IO or D).  Then set the state of the digital I/O line to off (0) to turn off the LED or on (1) to turn on the LED.  For example, connect your LED's cathode to a GND screw terminal and the anode to the IO0 screw terminal.  Then use the EDigitalOut function turn IO0 on and off.  Here's some pseudocode on this:

idnum = -1;  //Open first found U12
demo = 0;
channel = 0;
writeD = 0;
state = 1;
error = EDigitalOut(&idnum, demo, channel, writeD, state);  //Turn LED on
state = 0;
error = EDigitalOut(&idnum, demo, channel, writeD, state);  //Turn LED off

EDigitalOut is documented in the User's Guide, and use the the C# examples for help on C# syntax as the above is basically C without the .NET classes.  Here are links to helpful programming documentation:



You can also connect the anode to the AO0 or AO1 (analog output) screw terminal if you want more control of the voltage going to your LED.  Then use the the EAnalogOut function to set the voltage to about 0.0 V for off or a voltage between about 0.0 - 5.0 V for on.

I will point out that if you want to toy around with connections first without programming you can use the LJlogger sample program which is installed with the U12 Legacy software.  Here's the documentation on it in the User's Guide:



Are their known issues when using two LabJack U12 with the EDigitalOut function? We are currently using the .NET DLL, ver 1.21 of the driver, and VB.NET 2005. The problem we are experiencing is as follows:

1. EDigitalOut to set output 'n' on LJ #1. Output 'n' turns on.

2. Then turn use EDigital to set output 'm' on LJ #2. Output 'n' AND 'm' on LJ #2 turn on.

The problem occurs the other direction, as well.

We have tried our spare U12s with the same results.

Have you seen this issue before? I see that at one time you offered a solution for VB6 to allow putting each LJ device on a separate driver. Would you be able to provide that for .NET as well? I feel that might resolve my issue although I have been unable to find a way to do that with the existing DLL.

Your assistance to resolve this issue is appreciated.

We are not aware of any issues of this sort.  Do the U12s have different LocalIDs? 

The separate driver issue was specifically for someone who was having an issue while streaming.  It shouldn't be necessary in your case.

If you send your code to [email protected] we can take a look and figure out what the issue is.

Hi guys i've got problem with .... with everything. I tryed that program downloaded from this page (nettest) and when i run that only thing that work is set analog output but only at AO0 pin.... and Labjack is ok because when i run Labview program it works.... i have win7 64bit and i have ljackuw.dll too... please hlep me if you can

What sort of problem do you have with the C# example for the U12?  Do you get an errorcode?

If you remove all connections from the U12 except for USB, and then run LJtest, does it pass?

Yes LJtest and LJlogger works all right but when i try run c# program it doesnt work... it won't set and read digital IOs and from analog outputs i can control only one AO0... i don't get any error... it debug and run without problems but Labjack outputs do nothing.

How are you determining that AO1 is not working?  Perhaps you have DMM leads securely clamped into the AO1 & GND terminals?  If you use the control in LJlogger can you set AO1 as desired?

Looking at the C# example it seems to provide a convenience function SetAnalogOutput that only sets AO0.  Have you tried using LabJack.EAnalogOut(ref ljID, 0, -1.0f, voltage) to set AO1?  Read Section 4.2 about EAnalogOut.

To respond and get into more details of troubleshooting, please post on our forum.

I updated the C# example so that the SetAnalogOutput convenience function sets either AO0 or AO1 based on the channel parameter. Also, the example now uses the first found U12 instead of a U12 with local ID 0.

As for the digital IO related functions, they look like they are working. Keep in mind that if the writeD/readD setting is true (1), a D line is set/read. If set to false (0), a IO line is set/read.


How to read labjack's Pin in vb.net.

plz reply asap


Can you clarify what you mean by "pin"? Do you mean a U12's serial number, digital I/O (D and IO lines) or something else?

You can read the serial numbers of all connected U12s with the ListAll method, and for digital I/O you can use the EDigitalIn (single D or IO line) or DigitalIO (all D and IO lines) method.

The examples demonstrate VB.NET usage, and after adding a reference to the LJDotNet.dll assembly to your project you can use the Object Browser to view the LJDotNet assembly and its classes/methods.

The U12 driver's functions documentation is in the User's Guide. The LJDotNet assembly provides .NET wrapper methods to the driver's functions: