02-21-2012 11:49 AM
Hi all,
I'm creating my first application with the VisaNS driver with MS Visual Studio 2010 C# and I have added the NationalInstruments.Common and NationalInstruments.VisaNS as references. However, when i add the command "using NationalInstruments.VisaNS;" in the header of my main program. the build process returns the following error:
error CS0246: The type or namespace name 'NationalInstruments' could not be found (are you missing a using directive or an assembly reference?)
What am I missing here?
Thanks for your support.
Solved! Go to Solution.
02-21-2012 12:52 PM - edited 02-21-2012 12:54 PM
Hi all,
maybe I should give you more information which was returned by the compiler:
[...]\visual studio 2010\Projects\TCTest\TCTest\Form1.cs(14,7): error CS0246: The type or namespace name 'NationalInstruments' could not be found (are you missing a using directive or an assembly reference?) Compile complete -- 1 errors, 0 warnings Build started 2/21/2012 10:48:16 AM. ResolveAssemblyReferences: A TargetFramework profile exclusion list will be generated. c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "NationalInstruments.VisaNS, Version=9.0.40.156, Culture=neutral, PublicKeyToken=dc6ad606294fc298, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "NationalInstruments.Common, Version=9.1.40.159, Culture=neutral, PublicKeyToken=dc6ad606294fc298, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. CoreResGen: All outputs are up-to-date. GenerateTargetFrameworkMonikerAttribute: Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files. CoreCompile: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\GemBox Software\GemBox.Spreadsheet Free 3.5\Bin\NET40\GemBox.Spreadsheet.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\Microsoft.CSharp.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Deployment.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Drawing.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Windows.Forms.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Xml.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:"obj\x86\Debug\Thermal Compensation Test.exe" /resource:obj\x86\Debug\Thermal_Compensation_Test.Form1.resources /resource:obj\x86\Debug\Thermal_Compensation_Test.Properties.Resources.resources /target:winexe Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs
02-22-2012 06:09 PM
Hello schwabe111,
Do you have Measurement Studio on your computer? If you have this program on your computer you should have access to some VISA examples. These can be found under the National Instruments folder in your program files. National Instruments>>VISA>>Examples>>DotNET4.0
Paul-B
02-24-2012 11:16 AM
These errors can be generated when you have references to NI assemblies that are built for a different version of the .NET Framework than the project is using. It looks like you are using the .NET 4.0 assemblies. Likely your project is using the .NET 4.0 Client Profile which is a light-weight version of the full .NET 4.0 Framework and is not compatible with NI assemblies.
For C# projects navigate to Project Properties >> Application and change Target framework to .NET Framework 4.
03-29-2012 09:07 AM
thank you for you replay
i haved the same question but resolve the problem refer to your replay
thank you very much
05-24-2012 01:00 PM
Thanks! That worked for me
06-08-2012 03:29 PM
Hi,
I am facing a similar problem with nidaqmx with .net 4.0. I just cant get the samples to compile on Win7/64bit/VC#2010. I am referencing the current assemblies from the measurment studio 2010 folder. The error I get is:
Error 1 Assembly 'NationalInstruments.DAQmx, Version=9.5.40.112, Culture=neutral, PublicKeyToken=dc6ad606294fc298' uses 'NationalInstruments.Common, Version=9.1.40.163, Culture=neutral, PublicKeyToken=dc6ad606294fc298' which has a higher version than referenced assembly 'NationalInstruments.Common, Version=9.1.40.159, Culture=neutral, PublicKeyToken=dc6ad606294fc298' c:\Program Files (x86)\National Instruments\MeasurementStudioVS2010\DotNET\Assemblies\Current\NationalInstruments.DAQmx.dll AcqOneVoltageSample.2010
I tried referening the 9.5.40.112 and 9.1.40.159 together, with the same error. I even tried the 64bit vesions and still the same error.
Please advise, and thanks in advance.
Bakr
06-11-2012 11:01 AM
Hi Bakr,
There is a Knowledge Base article which addresses the issue you're running into. The steps listed should help you take care of the compile error.
Cheers,
06-11-2012 01:05 PM
Thank Kyle,
I removed all my daqmx 9.5.1 stuff, reinstalled and followed the knowledge base everything compiles fine right now.
thanks for the promt response,
Bakr
10-03-2016 04:29 PM
I am running M/S Windows 10 with Visual Studio 2013 Basic .NET 4.5 and trying to use National Instruments Visa. I have National Instruments Common 15 and National Instruments Visa15, and Ivi Visa 5.7 installed in the references extensions add in. Will this configuration work? As a first test I have put Imports NationalInstruments.Visa, Imports NationalInstruments.VisaNS, and Imports Visa.Ivi at the very top of my code file. There are no other build errors. All of these statements are flagged with errors that the namespace cannot be found. Any suggestions? Thanks.