01-04-2012 03:41 PM
Hi,
I installed VISA 5.1.1 on my windows 7 x86 machine. This is where I have visual studio 2010 installed. I am looking into writing software to control some equipment using GPIB. To start out with, I started to look at the .NET 4.0 examples. I tried to run SimpleReadWrite but it had the following error:
C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\DotNET4.0\SimpleReadWrite\cs\MainForm.cs(17,37): error CS0012: The type 'NationalInstruments.ISynchronizeCallbacks' is defined in an assembly that is not referenced. You must add a reference to assembly 'NationalInstruments.Common, Version=9.0.40.362, Culture=neutral, PublicKeyToken=dc6ad606294fc298'. C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\DotNET4.0\SimpleReadWrite\cs\MainForm.cs(17,37): error CS0012: The type 'NationalInstruments.ISupportSynchronizationContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'NationalInstruments.Common, Version=9.0.40.362, Culture=neutral, PublicKeyToken=dc6ad606294fc298'.
I than went to do what it said and add the NationalInstruments.Common reference but I can't find the version it says. The closest version I found is 9.0.40.159. I added that version and it works just fine on my Windows 7 machine but when I run it on my windows XP machine where my equipment is, it has the following error:
Where would I find the correct version of NationalInstruments.Common? Or how would I fix this issue?
Thanks,
Andy
01-05-2012 05:24 PM
Hi Andy,
From your description it looks like the issue is related to a mismatch of the NationalIntruments.Common assembly version.
You didn´t mentioned installing NI-488.2 drivers. Do you have them installed? If you don´t, I would suggest you to install the NI-488.2, any version later than 2.8.1 (3.0 is the latest version), as these versions have support for Visual Studio 2010 with .NET Framework 4.0 Languages (C# and Visual Basic.NET). You can download the driver here.
Regards,
Jorge
Applications Engineer
National Instruments
____________________________________________
Certified LabVIEW Associate Developer (CLAD)
01-06-2012 08:18 AM
Hi Jorge,
I did what you suggested and installed the NI-488.2 drivers (Version 3.0). I went and rebuilt the SimpleReadWrite project but it still had the same NationalInstrument.Common version error. I looked through the references I could add in VS2010 and I did not find NationalInstrument.Common version 9.0.40.362. I was hoping by installing the NI-488.2 drivers that it would install the missing version.
I did find a way around the issue yesterday. I created a app.config file to remap the missing version to the version I had and it seems to run now, I need to test it more. This is what I added:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="NationalInstruments.Common" publicKeyToken="dc6ad606294fc298" culture="neutral" /> <bindingRedirect oldVersion="9.0.40.362" newVersion="9.1.40.159"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Is there a better way to fix this issue? Or should I just go with the app.config workaround?
Thanks,
Andy
01-12-2012 02:25 PM
Hi Andy,
When you installed the NI-488.2 drivers, did you choose to install the .NET support? I ran the install of the NI-488.2 3.0 in my computer as a test and noticed that you need to explicitly select to install .NET Framework 4.0 Languages Support. May may want to try this to see if you get a different result.
Thanks,
01-18-2012 09:25 AM - edited 01-18-2012 09:26 AM
Hi Jorge,
I double checked, but I did install the .NET Framework 4.0 Language Support. To make sure it installed correctly, I did a repair on the NI-488.2 3.0 installation but still no luck. See Screenshot for installed components.
Any other suggestions?
Thanks,
Andy
01-27-2012 12:08 PM
Hi Andy,
I think this problem was solved in another post before, and the solution is explained in the following quote:
"When you create a project in VS Express, by default the target framework is set to ".NET Framework 4 Client Profile." This article from Microsoft explains what this means: http://msdn.microsoft.com/en-us/library/cc656912.aspx, but to summarize it breifly, this is a subset of the full .NET framework wherein you cannot reference any assemblies that are not included in the client profile. What you need to do is change the Target Framework to ".NET Framework 4." You can do this by right clicking on the project and opening the Properties, then go to the Compile settings and scroll down to the bottom and open the "Advanced Compile Options..." button. "
I would suggest you to try this.
Thanks.
01-27-2012 01:22 PM
Hi Jorge,
The project is actually already targeting ".NET Framework 4."
Thanks!
Andy
02-06-2012 02:32 AM
I am having an identical problem. Installed the latest (as of Febuary 1st) NI-GPIB drivers, 3.0. Chose the .NET 4 support at installation. Started up the SimpleReadWrite solution in C# Express 2010 and when I compile I receive the following the errors
Error 1 The type 'NationalInstruments.ISupportSynchronizationContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'NationalInstruments.Common, Version=9.0.40.362, Culture=neutral, PublicKeyToken=dc6ad606294fc298'. C:\Users\Public\Documents\National Instruments\NI-488.2\Examples\DotNET4.0\SimpleReadWrite\cs\MainForm.cs 23 24 SimpleReadWrite.2010
Error 2 The type 'NationalInstruments.ISynchronizeCallbacks' is defined in an assembly that is not referenced. You must add a reference to assembly 'NationalInstruments.Common, Version=9.0.40.362, Culture=neutral, PublicKeyToken=dc6ad606294fc298'. C:\Users\Public\Documents\National Instruments\NI-488.2\Examples\DotNET4.0\SimpleReadWrite\cs\MainForm.cs 23 24 SimpleReadWrite.2010
The build target is already .NET 4.0 and when I go to add a reference to the above assembly, I only see version 9.1.20.159 and 9.1.35.159. I can add either, but get the same error.
02-06-2012 02:43 AM
The assembly binding redirect trick with the app.config does not work either.
Note : I'm using Windows 7, not Windows XP like the original poster.
02-06-2012 03:13 AM
Ok, I got it to work with an assembly NationalInstruments.Common 9.1.40.159.... It did not work with 9.1.20.159, or 9.1.35.159. All 3 are listed, although 9.1.20.159 and 9.1.35.159 are listed first, and together.