Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Does the NI488.2.NET Wrapper Language Interface work also with C++ 2005 or C++.Net?

When I try to include the "LangInt.dll" or "NationalInstruments.NI4882.dll" into my C++2005 Express Edition Project the compiler reports several errors of this kind:

c:\dokumente und einstellungen\axel\eigene dateien\visual studio 2005\projects\locures2005\locures2005\NationalInstruments.NI4882.dll(1) : error C2018: unknown character '0x5'

Is this a problem of the compiler options or are these dll's not usable for C++?

0 Kudos
Message 1 of 8
(5,368 Views)
Hello

Are you using MFC or managed C++ (C++/CLI)? Is this error happening with any .NET assembly or just the ones mentioned here?

It would help if you could attach a sample project that helps reproduce this problem.

Thanks

Bilal Durrani
NI
0 Kudos
Message 2 of 8
(5,359 Views)
Hello Bilal Durrani,
 
I use only managed C++-code with compiler option \clr. The probleme is the same with Visual C++.net 2003 or C++ 2005 express edition. I have attached both kinds of projects. The projects are simple Windows Form / Console application doing nothing. I just added the the two lines:

#include

"NationalInstruments.NI4882.dll"//"LangInt.dll"

using

namespace NationalInstruments::NI4882;

and added the reference and the path to the project properties.

Will this help you to resolve my problem?

Thanks for your efforts!

Axel Helmbold

0 Kudos
Message 3 of 8
(5,350 Views)
You don't need the include statement, since there is no type library and it is a managed assembly. Once you add a reference , all you need is

using namespace NationalInstruments::NI4882;

BTW, the langint.dll is not the recommended solution. The above library (found under C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Assemblies\Current ) provides a much cleaner object oriented interface. It also provides a more natural .NET programming experience by representing programming idioms in a manner consistent with the rest of the .NET Framework. It will continue to be supported and will definitely be supported in Visual Studio 2005 and .NET Framework 2.0.

langint.dll, on the other hand, is a flat wrapper on top of the C API. Its purpose is to help developers who are very familiar with the C API and just want to port a C program to .NET (likely C#).

I hope this helps.

Bilal Durrani
NI
0 Kudos
Message 4 of 8
(5,347 Views)

Thanks for your advise. Sometimes it is much simpler then I thought. Do you know if there is a guideline to the notification of the gpib commands given by the Net-Interface? All I know till now are the ib... statements of the common API explained in the documentation comming with the hardware. The commands in the Browser seems to be different. Or is there a sample code availible. The NET-samples from the standard instalation of the NI488-software seems to be only relevant if you use the langint.dll.

Thanks a lot.

Axel Helmbold

0 Kudos
Message 5 of 8
(5,333 Views)
There is help for the NationalInstruments::NI4882 interface, but since you only have VS 2005 installed, you wont be able to see the help. The help for that interface is created using the VS 2003 help system, which is different from the VS 2005 Help system. You should have the help files installed, you just need a help viewer. You can use the free H2 Viewer to do this. You should have the appropriate .HXs files installed under C:\Program Files\National Instruments\MeasurementStudioVS2003\Help.


Bilal Durrani
NI
0 Kudos
Message 6 of 8
(5,323 Views)
Hello Bilal Durrani
Thank You for the guideline to view the NI4882 Interface help. I have started to program and write and read works without problem. There is still some trouble with the

NotifyCallback Delegate. In the C# and VB examples the syntax is :

testDevice.Notify(GpibStatusFlags.DeviceServiceRequest, new NotifyCallback(testDevice_Notify), "Sample user data");

with only 1 parameter in the 2.parameter. Within the Measurement Studio help NotifyCallback has 2 Parameter :

public delegate void NotifyCallback(
   
object sender,
   
NotifyData notifyData
);

If I adapt the style how to initialize a thread in C++ and use the notation:

m_GPIBDevice->Notify(GpibStatusFlags::DeviceServiceRequest, gcnew NotifyCallback(gcnew C_MyClass,&C_MyClass::_Notify), "some text");

and

void C_MyClass::_Notify(System::Object^ sender, NotifyData^ e){...}

There is no compiler error but when running the application the following error message appears:

"Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'c:\Dokumente und Einstellungen\Axel\Eigene Dateien\Visual Studio 2005\Projects\FFCCT_2\debug\FFCCT_2.exe'.
Additional Information: A call to PInvoke function 'NationalInstruments.NI4882!g::a' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."

Can you tell me something about the correct notation?

Thank You very much!

Axel Helmbold

0 Kudos
Message 7 of 8
(5,313 Views)
This message should not affect the behavior of your program. You can continue execution of your application by ignoring this error message (hit Continue).
You get this MDA message only with the debugger attached so you would not see the problem in a release application. See this link on how to turn off this message. Or just go to the BUild >> Exceptions menu.

I verified that there was no actual stack corruption. The debugger might be getting this false positive because this is a .NET 1.1 library. When we release the NET 2.0 library for NI488, this problem will no longer exist.

If you still run into problems after turning this off, let me know.
Bilal Durrani
NI
0 Kudos
Message 8 of 8
(5,301 Views)