LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a dll file that is created in Visual C#

Hi All,

 

I am using a device (an attenuator) that needs to be controlled via USB port. When I connect the attenuator to the computer via USB, a virtual COM port gets assigned to the attenuator. The company that I bought it from, only gave me a *.dll file and some global methods to control the device. I am working on CVI8.0 and I am not sure as to how I can use it to my need. Can I load the *.dll module somehow and put the *.dll in my working directory? Also, I am not sure how to control the device via LabWindows using USB port. Any help on this will be appreciated. 

 

Thank you! 

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

Hi qsa,

DLL files created in C# (.NET) are not typical C/C++ DLLs, rather they are .NET Assemblies and need to be called/treated different than regular DLLs.

To help with calling .NET Assemblies from C Code, CVI provides a tool called .NET Controller Wizard which is basically a tool that will create a thin wrapper around the functions/properties exported by the .NET Assembly so that you can call them from CVI easily. This proccess not only creates the wrapper, but also creates an Instrument Library for calling the functions, including  CVI Function Panels and Help.

To access this tool, click Tools >> Create .NET Controller from CVI.
For help on this wizard refer to CVI Help: Create LabWindows/CVI .NET Controller Dialog Box


Hope this helps!

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 2 of 5
(4,022 Views)

qsa301, 

 

Did you provider specified that you have to register the dll before using it ? Do you have some documentation, a list of methods and their input/output parameters, that are exported by the library ?

 

Beside what Jervin mentioned about .NET, an ActiveX server can also be in that dll. You also have an "ActiveX Controller Wizard", in the tools menu, with which you can generate an instrument driver for a selected ActiveX server. Using the wizard you can see all objects, methods, and properties of the selected ActiveX server and you can select which methods and properties you want CVI to create wrapper functions for.

 

Regards

0 Kudos
Message 3 of 5
(4,000 Views)

Thank you very much for your relply. I generated the .NET Controller using MS Framework 3.5. It generated an Instrument Library,  a FP and *.c/*.f files that have a some CVI Functions. Can you please guide me as to where to go from here because I have never used it it before. How can I make calls to the functions that manufacturer has provided me, using the wrapper that I have generated?

 

Thank you! 

0 Kudos
Message 4 of 5
(3,987 Views)

qsa301,

 

The .NET Controller Wizard generated you an Instrument Library and all supporting files necessary for wrapping the functions contained in your assembly.  After stepping through the wizard, the Instrument (*.fp) was probably loaded into your CVI environment under the Instruments folder (check the lower left portion of your environment).  This Instrument should contain all functions necessary for interfacing with the methods in your assembly.  Simply make calls to the functions in the Instrument, and as a wrapper, it will interface with the appropriate corresponding method in the assembly and take care of the rest.

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 5 of 5
(3,958 Views)