01-18-2012 11:38 AM
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();
}
}
}
01-19-2012 09:38 AM
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