From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace 'NationalInstruments' not found

Solved!
Go to solution

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.

0 Kudos
Message 1 of 12
(13,851 Views)

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

 

0 Kudos
Message 2 of 12
(13,848 Views)

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

Applications Engineer
National Instruments
0 Kudos
Message 3 of 12
(13,836 Views)
Solution
Accepted by topic author schwabe111

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.

National Instruments
Message 4 of 12
(13,825 Views)

thank you for you replay

 

i haved the same question but resolve the problem refer to your replay

 

 

thank you very much

0 Kudos
Message 5 of 12
(13,758 Views)

Thanks! That worked for me

0 Kudos
Message 6 of 12
(13,662 Views)

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


0 Kudos
Message 7 of 12
(13,612 Views)

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,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 8 of 12
(13,601 Views)

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

0 Kudos
Message 9 of 12
(13,595 Views)

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.

0 Kudos
Message 10 of 12
(8,959 Views)