Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing NI-SCOPE DLL into VB.NET

In order to use the NI-SCOPE functions in VB.NET, is it necessary to use the attribute for each and every function we wish to use?
0 Kudos
Message 1 of 8
(7,303 Views)
Yes. niscope_32.dll does have a type library that provides function and constant declarations, so in VB6 you could just add a reference to the dll. This type library only contains function declarations and constants, though, not COM coclasses, COM interfaces, etc. The .NET framework tlbimp tool will create an interop assembly for COM coclasses, COM interfaces, enums, constants, etc., but will not do anything for global function declarations. VB.NET uses tlbimp to generate its interop assemblies behind the scenes, hence you will need to create DllImport statements for the functions in niscope_32.dll that you want to use.

- Elton
Message 2 of 8
(7,303 Views)
Thanks for the clarification and explanation. This change in .NET makes it more tedious to program external instrumentation, but I suppose it does force you to list your functions you will use for better organization and planning...
0 Kudos
Message 3 of 8
(7,303 Views)
Hi Elton,

Can you give a simple step-by-step approach of doing this in C#? I'm having trouble finding any information on doing this on NI's site. I'm concerned about importing functions that depend upon NI's objects, like ViSession. Any help would be greatly appreciated!

Thanks,
Derek
0 Kudos
Message 4 of 8
(7,303 Views)
Take a look at Consuming Unmanaged DLL Functions in MSDN. It is a very detailed step-by-step walkthrough of how to create DllImport declarations for functions that you want to call in unmanaged .dll's.

- Elton
0 Kudos
Message 5 of 8
(7,303 Views)
Thanks for the link. My biggest problem was trying to determine the function signatures and how the NI object types mapped to their .NET counterparts. For example, how do you determine what ViSession maps to? From an example it seems to be System.UInt32.
0 Kudos
Message 6 of 8
(7,303 Views)
We are currently working on a tool to generate .NET interfaces around instrument drivers, to be included as part of MeasurementStudio. I have included the generated vb class wrapper for niscope below. Please note that this code has not been thoroughly tested. However, if you have any problems with it please feel free to contact me - your experience with this wrapper will help us to improve our tool to generate better code.
0 Kudos
Message 7 of 8
(7,303 Views)
Hi Glenn,

Thanks for the code! I'm anxiously awaiting the release of this tool as our current application uses the niScope and niFgen dlls. You wouldn't have the C# wrappers for these would you? Or a beta of the tool itself? I've created the wrappers myself in C#, but I would like to verify that I translated them correctly and included everything. It was a painful by-hand process that I wouldn't want to do again!

Thanks,
Derek
0 Kudos
Message 8 of 8
(7,303 Views)