Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx deployment with VS2010

Hi,

 

We developed an application using VisualStudio 2010, .NET 4.0, target x86, NI-DAQ 9.4 driver and a NI-6210 USB. It works fine on our development computers but we're experiencing issues when deploying it.

 

We want this application to run even if the DAQmx-Core / DAQmx driver is not installed. In this case, of course, no data are acquired but the program must start and warn the user that the driver has not been found. However, our program crashes at startup if the driver is not installed, displaying this exception "Unable to liad the file or assembly NationalInstruments.DAQmx.dll or one of his dependancies".

 

The VisualStudio deployment project seems to detect the right dependancies has shown below.

 

NI_001.png

 

The installation ends up fine and the DAQmX.dll library is copied on the target computer at the root of our program directory, the other NI files are in the GAC folder.

 

Are we missing something ?

How is it possible for our application not to crash on startup if DAQmx isnt installed ?

 

Thank you for support,

Regards,

Florent.

0 Kudos
Message 1 of 8
(6,866 Views)

Hi Florent,

 

Thank you for posting on NI's Discussion forum.

 

Have you selected the component for .NET when you have installed NI-DAQmx driver ?

 

Regards,

0 Kudos
Message 2 of 8
(6,834 Views)

Hi Vincent,

 

Thanks for your answer.

 

The component for .Net has been installed on our development PCs but isn't on the target one. As I explained, we expected our program to run (and warn the user that he cannot acquire any data) even if the driver is not installed. Dependancies are correctly detected and NI.DAQmx.dll is copied on the target computer but it doesn't work...

 

In fact, our customers use the same program to acquire datas (on a laptop) and then to process it on another computer (at the office). They don't need the NI driver on the office computer because no NI interfaces are connected.

 

Regards,

Florent.

0 Kudos
Message 3 of 8
(6,831 Views)

Hi Florent,

 

I suggest you to try this :

In Visual Studio 2010, go to Project -> Properties -> Compile -> Advance Compile Options. Set the target Framework to .NET framework 4

 

Then you should be able to see National Instruments.DAQmx.dll with the other dependencies of your project.

 

I hope this helps,

 

Regards,

 

 

0 Kudos
Message 4 of 8
(6,822 Views)

Hi Vincent,

 

The target framework is already set to .NET 4, the target platform is x86. And the merge module mstudiodaqmx.2010.msm is detected as a dependancy (as shown on the attached picture in my first post) in my deployment project. NationalInstruments.DAQmx.dll library is copied on the target computer at the root of our program directory but I get this exception when DAQmx driver isn't installed whereas the program is not trying to communicate with an NI interface. It's only loading the DAQmx.dll to know if an interface is aivalable.

 

Sans titre.png

 

I hope my post is clear now,

Regards,

Florent.

0 Kudos
Message 5 of 8
(6,819 Views)

Hi Florent,

 

I'm trying to find any document which could be helpful for you, i found this KB thanks to a previous post one the Forum.

 

After reading again you first post i saw that you put NationalInstruments.DAQmx.dll in the root of you program directory, can you try to put it in the GAC folder ?

 

Regards,

 

0 Kudos
Message 6 of 8
(6,807 Views)

Hi Vincent,

 

I had already found this KB and followed its instructions. The right merge modules are automatically detected by Visual Studio so I think this step is fine.

 

I did not copy manually the NationalInstruments.DAQmx.dll file in my program folder but the deployment project did and I don't kow why because the other NI assemblies are in the GAC folder. I copied manually the NationalInstruments.DAQmx folder from my computer's GAC_32 folder to the target computer but the exception remain the same. However I think this kind of files needs an installer to be recognized by Windows...

 

I tried to add / delete these files on my computer. If C:\ Windows\ Microsoft.NET\ assembly\ GAC_32\ NationalInstruments.DAQmx\ v4.0_9.4.40.50__dc6ad606294fc298\ NationalInstruments.DAQmx.dll and C:\ Program Files\ MyProgram \NationalInstruments.DAQmx.dll are deleted at the same time then the program is crashing the same way than on the target computer. If only one of the 2 files exists, it works.

 

Thanks for your help,

Regards,

Florent.

0 Kudos
Message 7 of 8
(6,795 Views)

In response to your statement "We want this application to run even if the DAQmx-Core / DAQmx driver is not installed. In this case, of course, no data are acquired but the program must start and warn the user that the driver has not been found".

 

You have a couple of options:

  1. Check to see if a core DAQmx driver DLL is installed on the system. If not, display an error message to the user. See the DAQmx: Checking if DAQmx is Installed and Which Version is Installed. That example is in LabVIEW but its a simple test that can be done in .NET. If the file exists, show a message.
  2. You could do a try/catch around your method call that does the data acquisition and check for the FileNotFoundException. If the exception is thrown because it can't load DAQmx.dll, you could display a message to the user.

Snippet.png

 

The snippet above should work as I tested it on a machine with just the DAQmx assemblies installed and not the underlying driver.

 

Hope this helps.

 

 

 

Jonathan N.
National Instruments
0 Kudos
Message 8 of 8
(6,756 Views)