NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
schwabe111
Posts: 15
0 Kudos
Accepted Solution

Namespace 'NationalInstruments' not found

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.

Member
schwabe111
Posts: 15
0 Kudos

Re: Namespace 'NationalInstruments' not found

[ Edited ]

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

 

Member
Paul-B
Posts: 75
0 Kudos

Re: Namespace 'NationalInstruments' not found

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
Active Participant
D_Biel
Posts: 643

Re: Namespace 'NationalInstruments' not found

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
Product Support Engineer
Member
goldramer
Posts: 4
0 Kudos

Re: Namespace 'NationalInstruments' not found

thank you for you replay

 

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

 

 

thank you very much

Member
ThomasA@Mensor
Posts: 1
0 Kudos

Re: Namespace 'NationalInstruments' not found

Thanks! That worked for me

Member
Bakr Younis
Posts: 2
0 Kudos

Re: Namespace 'NationalInstruments' not found

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


Member
KyleP
Posts: 129
0 Kudos

Re: Namespace 'NationalInstruments' not found

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
Member
Bakr Younis
Posts: 2
0 Kudos

Re: Namespace 'NationalInstruments' not found

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

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page