10-27-2011 05:48 AM
Hi,
I have been asked to develop a simple gui to take readings from an SR830 DSP Lock-In Amplifier via a PCI-GPIB card. As a starting point I have been trying to get one of the example programs that came with the GPIB card to work. I was trying to modify the C examples into a working windows forms gui with Visual C++, but found that I could not get it to work with any of the dll's or obj files (ni4882.dll, ni4882.obj, gpib-32.dll, gpib-32.obj). After a discussion with an N.I. technical support guy I was told that because these libraries are unmanaged, I wouldn't be able to get it to work at all. He advised me to either try programming it in VC# or VB, or in labview. Now, I'm reasonably experienced in numerical programming, mainly in C++, but all this gui and .net stuff is very new to me and I am learning on the job. So please bare with me!
I have decided to try and do this in VC#, mainly because it's a language I want to gain familiarity with. So now, I've started again with a new starting point... trying to get the .NET3.5 VC# example 'SimpleReadWrite' to work. However, when I try and compile this I get the error message below. I have located the NationalInstruments.Common.dll and NationalInstruments.NI4882.dll files and feel pretty confident that somehow I have to reference these as assemblies or something? But I do not have any idea how to do this. Please could someone point me in the right direction, or better still tell me exactly what I need to do!
Thanks (and sorry if I sound like a complete novice... I am!)
Nick
btw I'm using Visual Studio 2008
------ Build started: Project: SimpleReadWrite.2008, Configuration: Debug Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "NationalInstruments.NI4882, Version=9.0.35.157, Culture=neutral, PublicKeyToken=18cbae0f9955702a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "NationalInstruments.Common, Version=9.0.35.362, Culture=neutral, PublicKeyToken=18cbae0f9955702a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702 /nostdlib- /platform:AnyCPU /warn:4 /baseaddress:285212672 /define:DEBUG;TRACE;NETFX3_5 /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /filealign:4096 /optimize- /out:obj\Debug\SimpleReadWrite.exe /resource:obj\Debug\NationalInstruments.Examples.SimpleReadWrite.MainForm.resources /target:winexe /warnaserror- /win32icon:App.ico AssemblyInfo.cs MainForm.cs
C:\Documents and Settings\naustin\Desktop\SimpleReadWrite\SimpleReadWrite\cs\MainForm.cs(7,27): error CS0234: The type or namespace name 'NI4882' does not exist in the namespace 'NationalInstruments' (are you missing an assembly reference?)
C:\Documents and Settings\naustin\Desktop\SimpleReadWrite\SimpleReadWrite\cs\MainForm.cs(23,17): error CS0246: The type or namespace name 'Device' could not be found (are you missing a using directive or an assembly reference?)
Compile complete -- 2 errors, 0 warnings
Done building project "SimpleReadWrite.2008.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
10-27-2011 12:56 PM
@NickAustin wrote:
I was trying to modify the C examples into a working windows forms gui with Visual C++, but found that I could not get it to work with any of the dll's or obj files (ni4882.dll, ni4882.obj, gpib-32.dll, gpib-32.obj). After a discussion with an N.I. technical support guy I was told that because these libraries are unmanaged, I wouldn't be able to get it to work at all.
I don't understand this. Were you trying to create an MFC app, or did you select "Windows Forms Application" in the project wizard? The latter creates a .NET project.
As for you second attempt, it appears that you do not have the required assemblies installed. When you run the NI-488.2 installer, you need to explicitly select to install .NET support. Thus, rerun the installer, and in the tree under "Development Support" select to install the .NET libraries.
By the way, drivers for that device exist. They're in LabWindows, but LabWindows is just ANSI-C, so you should be able to make use of them.
10-28-2011 02:48 AM
I was doing a windows forms project... but it's alright, I got it working. I just had to change the common language runtime support to /clr from /clr:pure so it would be less picky about the libraries it could be seen with! As for the C# project, I suspected that might be the case... unfortunately due to various constraints I am programming on a different machine to the one with the card installed. Anyway, all is good as I've got it working in VC++ 🙂
10-28-2011 02:50 AM
Thank you for your reply anyway 🙂