Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

FileNotFoundException from VisaNS, with detailed error message

Hi there,

 

I wrote a small application in Visual C# 2008 which uses MessageBasedSession for TCP/IP socket communication.

It works fine on one PC which had a Measurement Studio (evaluation copy) installed. But after I copy the project solution to another PC which has only VisualStudio2008 but not Measurement Studio, it gave me "FileNotFoundException".  I did install NI-Visa .NET assemblies and referenced NI.VisaNS and NI.Common, and the project built successfully.  It seems to be looking for a specific version of NI assembly that is older than my installed NI assemblies.

 

I suspect that if I install Measurement Studio on the PC it might work fine. But in this project I only use MessageBasedSession and nothing else from MeasureStudio. It should run without MeasureStudio, right?  Please help. I copy the error message below FYI.

 

Many thanks!

Harry

 

========== Detailed Error Message ========================

 

System.IO.FileNotFoundException was unhandled
  Message="Could not load file or assembly 'NationalInstruments.Common, Version=8.9.35.156, Culture=neutral, PublicKeyToken=18cbae0f9955702a' or one of its dependencies. The system cannot find the file specified."
  Source="MCBTest1"
  FileName="NationalInstruments.Common, Version=8.9.35.156, Culture=neutral, PublicKeyToken=18cbae0f9955702a"
  FusionLog=""
  StackTrace:
       at MKS.Online.MCBTest.MainForm.openSession_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at MKS.Online.MCBTest.MainForm.Main() in C:\Home\miniMCB\MCBTest\MainForm.cs:line 559
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileNotFoundException
       Message="Could not load file or assembly 'NationalInstruments.Common, Version=8.7.35.131, Culture=neutral, PublicKeyToken=18cbae0f9955702a' or one of its dependencies. The system cannot find the file specified."
       FileName="NationalInstruments.Common, Version=8.7.35.131, Culture=neutral, PublicKeyToken=18cbae0f9955702a"
       FusionLog="=== Pre-bind state information ===\r\nLOG: User = MKS\\ZhangH\r\nLOG: DisplayName = NationalInstruments.Common, Version=8.7.35.131, Culture=neutral, PublicKeyToken=18cbae0f9955702a\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Home/miniMCB/MCBTest/bin/Debug/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : NationalInstruments.VisaNS, Version=8.9.35.108, Culture=neutral, PublicKeyToken=18cbae0f9955702a.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\\Home\\miniMCB\\MCBTest\\bin\\Debug\\MCBTest1.vshost.exe.Config\r\nLOG: Using machine configuration file from c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Redirect found in application configuration file: 8.7.35.131 redirected to 8.9.35.156.\r\nLOG: Post-policy reference: NationalInstruments.Common, Version=8.9.35.156, Culture=neutral, PublicKeyToken=18cbae0f9955702a\r\nLOG: The same bind was seen before, and was failed with hr = 0x80070002.\r\n"
       InnerException:

 

0 Kudos
Message 1 of 4
(4,314 Views)

Harry,

 

The two assemblies you mentioned (NationalInstruments.VisaNS and NationalInstruments.Common) should have both been installed with the NI-VISA driver.  The error message seems to indicate there is a problem with an app config file.  Our assemblies come with policy files that should handle redirects like this, so you shouldn't need any explicit redirects in your app config file if you have them.

 

Is this error message a run-time error or a build error?

 

Can we see what versions of NationalInstruments.Common you have installed on this second computer?  Seeing the policy files would be helpful as well.  Just take a screenshot of C:\Windows\assembly, scrolled down to the NationalInstruments.Common assemblies and another screenshot scrolled down to the policy.x.x.NationalInstruments.Common .

Eric B.
National Instruments
Message 2 of 4
(4,299 Views)

Hi Eric,

You are absolutely right!  The program works fine after I removed the application config file. I did not even notice its existance in my project/solution.  It was robably carried over from the old project created on another PC.  It caused run-time error as soon as I started my application.

 

BTW, I want to confirm with you on one thing:

As I mentioned, the only thing I used in my small program is a MessageBasedSession from NIVisaNS class. What is the minimum requirements if I deploy my program to run on another PC (vanilla)?  I should have to install full Visa drivers, but presumably I still need to manually install Visa RunTime engine?  Is there anyway to include everything needed in the Visual Studio setup project?

 

Many thanks in advance!

0 Kudos
Message 3 of 4
(4,283 Views)

Shef,

 

 Information about VISA licensing and deployment can be found here: http://www.ni.com/visa/license.htm?node=12145 .  Basically, if you are using an NI development environment on the deployment machine (LabVIEW, TestStand, CVI, Measurement Studio), or if you are using NI hardware on the deployment machine, you are licensed to install VISA on that deployment machine.  Otherwise, you need to purchase a deployment license.

 

To actually create your deployment, you can create a setup project and add your project output and the dependencies will be automatically detected.  This adds .msm files (merge module files) to your setup project that make everything get packaged up correctly.  Step-by-step instructions can be found here: http://digital.ni.com/public.nsf/allkb/ED87C183E056CAC386256DF1004E54C6?OpenDocument

Eric B.
National Instruments
0 Kudos
Message 4 of 4
(4,260 Views)