Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Examples using USB-8452 with C#

I would like to use the NI USB-8452 with Microsoft C# and Visual Studios 2013.

I found the  NI Knowledge Base paper: "How Can I Access USB-845x API Function from a C/C++ Program?"

 http://digital.ni.com/public.nsf/allkb/F997E364CFAA63F6862573540064C028

Although This was very helpful, I am still having trouble converting it to C#.

Does anyone have any examples, specific to C#, that they can share with me?

Thanks,

Ken

0 Kudos
Message 1 of 5
(4,008 Views)

Hey,

That document describes the location of ni845x.dll, which contains the functions. I believe you can access them using C#.

 

Access a method from a DLL from C# program

Call function from DLL?

0 Kudos
Message 2 of 5
(3,981 Views)

NI Package Manager indicates NI-845x v21.3.0 is installed.

Ni845x.dll is in C:\Windows\System32.

 

Visual Studio 2019 does NOT offer anything with NI845x as a Reference for adding to a C# project.

Attempts to browse and install either ni845x.dll or ni845x.lib result in "A reference [...] could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.".

 

Examples and instructions for use instruct to "add to project"... as if it were actually possible, with no explanation (including what name to look for).

 

Please advise known reasons for not finding a Reference, when installation software indicates the driver was installed successfully.

 

Thank you!

 

0 Kudos
Message 3 of 5
(2,125 Views)

Hello, I am having the same problem. Did you solved the problem.

Sincerely

 

0 Kudos
Message 4 of 5
(1,570 Views)

I did figure it out.

I used NI's link:

Using the USB-845x API Functions in a C/C++ Program - NI

 

National Instruments supplies a DLL, Ni845x.dll, as part of their USB-8452 driver.
You must install NI's driver to use this C# file.
They supply a header file, ni845x.h to use their DLL with C/C++
All we need to do is figure out how to call these functions from C#
The attached file is based on ni845x.h.
The function prototypes are commented out and replaced with DLLImport functions.
This file may not be complete, or even correct, but it worked for me.

Good Luck

 

 

0 Kudos
Message 5 of 5
(1,541 Views)