Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NationalInstruments.common version error in simple WPF VISA console

I'm trying to compile the following c# code for a simple WPF GPIB console using VISA. It's essentially taken from "Visa and GPIB App development using C# or VB.net" walkthrough. I have VISA 5.11 installed and I'm referencing the current versions of the .common and .VisaNS files in the VS2010 project, which are 9.1.40.159 and 9.1.40.156, respectively. I get the following errors on the mbSession declaration line at compile-time:

 

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'.

 

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'm hesitant to download and include this older version that it's asking for as I want to try to avoid any additional compatibility issues further down the road. Any suggestions?

 

 

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using NationalInstruments.VisaNS;

namespace _8510_VISA_Console
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private MessageBasedSession mbSession;
private String resourceString;
private String stringToWrite;

private void button_init_Click(object sender, RoutedEventArgs e)
{
try
{
mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().
Open(resourceString);
}
catch (InvalidCastException)
{
MessageBox.Show("Resource selected must be a message-based session");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}

private void button_query_Click(object sender, RoutedEventArgs e)
{
try
{
textBox_response.Text = mbSession.Query(textBox_commandEntry.Text);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}

private void button_write_Click(object sender, RoutedEventArgs e)
{
try
{
mbSession.Write(textBox_commandEntry.Text);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}

private void button_read_Click(object sender, RoutedEventArgs e)
{
try
{
textBox_response.Text = mbSession.ReadString();
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}

private void button_closeVISASession_Click(object sender, RoutedEventArgs e)
{
mbSession.Dispose();
}
}
}

0 Kudos
Message 1 of 2
(4,213 Views)

Hey dpm5109,

 

I found a KnowledgeBase that talks about compile issues, the last 2 paragraphs I think can help you with this http://digital.ni.com/public.nsf/allkb/17146CC2A32D47338625712D005E4CC8

 

Hope this helps

BeauH
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(4,205 Views)