Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx declarations without DAQmx drivers loaded on target PC cause fatal

Solved!
Go to solution

I have a class with DAQmx declarations.  If the application is installed on a system without Measurement & Automation (MAX) and supporting driers installed, just instantiating my class will cause my application to crash. 

How do I trap the error or check if DAQmx will function before my class instantiation?

 

Below are examples of the declarations:

 

Private counter0BufReadTask As Task = Nothing

Private counter0BufRunningTask As Task = Nothing

Private counter0BufReader As CounterReader = Nothing

Private counter0BufCallBack As AsyncCallback = Nothing

Private counter0BufAr As IAsyncResult = Nothing

 

 

0 Kudos
Message 1 of 8
(4,712 Views)

Hi fjm1,

 

Does your whole computer crash or just the application?  What programming language are you coding your application in? what hardware are you plannig on using?  Do you get any errors associated with the crash?  Why do you try to run this without installing the DAQmx driver?  Have you tried this with DAQmx installed?

Regards,
Jim Schwartz
0 Kudos
Message 2 of 8
(4,693 Views)

Only the application crashes.  If I don't instanstiate my class, the app will keep running.

 

Versions: 

VB.Net 2008

Mesurement Studio v8.6

 

Hardware:

PCI-6154

PCI-6220

 

This application currently runs on several machine PC's creating data files.  The application also analyzses the data collected. Thus, end users like install it on their PC's for further data analysis.  If MAX is installed properly on their PC's, it runs with no problems.  However, they never use the MAX or DAQmx portion of the aapplication.  I would like to included in my Setup project all files necessary to install and run the application on user PC's without installing MAX.

 

What are the supporting DLL's for NationalInstruments.DAQmx.dll that are loaded by MAX?  Can these be included in my setup?

 

Of course, I always have the option to rewrite a portion of my code to allow for the one class to not be instantiated if running on a user PC.

 

0 Kudos
Message 3 of 8
(4,690 Views)
Solution
Accepted by topic author fjm1

Hi fjm1,

 

 One thing that you could do is to include the NI-DAQmx configuration runtime with your installer.  This is a smaller version of DAQmx and would keep your application from crashing. Your final statement is the other option.

Regards,
Jim Schwartz
0 Kudos
Message 4 of 8
(4,672 Views)

Hi Jim,

 

Thanks for the info.  I am going to focus on the rewrite.  The smaller footprint is still over 500MB.

 

Can you tell me what changed when Measurement Studio's went to .Net and DAQmx?  I have used VB6 with an older version of Measurement Studios and Traditional NI-DAQ.  Same scenario with no issues.

0 Kudos
Message 5 of 8
(4,665 Views)

fjm1 -

 

The .NET runtime loads the .NET assembly that defines the data types you are referencing in your code as soon as the code executes, even though you are not creating instances of those data types. The DAQmx .NET class library (NationalInstruments.DAQmx.dll) links directly to the internal user-mode  DAQmx driver DLLs. So, NationalInstruments.DAQmx.dll fails to load if the driver DLLs are not present. This direct linkage yields performance benefits that we deemed to be more important in more cases than providing an abstraction layer to directly support a delay-load scenario like the one you require.

 

However, your scenario is still viable. There are a couple of ways that you can handle it.

  1. Put the code that instantiates your class inside a try/catch and catch System.IO.FileNotFoundException. If you get the exception, it is likely caused by the DAQmx driver not being on the system. I did some quick tests and found that the type resolution occurs as soon as the block containing the declaration is entered. This means that putting a Try/Catch directly around your DAQmx type declarations won't work - you need to put the declarations inside a separate code block (e.g., a Sub or Function).
  2. Before instantiating your class, check for the presence of one of the DAQmx driver DLLs in the %System% directory. I recommend checking for the presence of "nidmxfu.dll" because
    NationalInstruments.DAQmx.dll depends on it directly. The same caveat applies as above, you'll want to put the conditional check around your class construction, not inside your class constructor.


 

If it were me, I'd go with option #2 because it seems like you don't consider the absence of the DAQmx driver to be an error condition. Generally, exceptions are best reserved for error conditions.

 

David Rohacek

National Instruments

Message Edited by drohacek on 10-16-2009 01:09 PM
Message Edited by drohacek on 10-16-2009 01:10 PM
Message 6 of 8
(4,645 Views)

David,

 

Great explanation.  I have tried the try/catch and ran into the same issue as you.  I like option 2 and will pursue it.

 

Thanks,

Frank

0 Kudos
Message 7 of 8
(4,623 Views)

hi,

I have the same problem, but I cannot catch anything. and I searched on the computer, it has the drivers.

but it always crash..I really do not know how to deal with it.

please help.

0 Kudos
Message 8 of 8
(3,156 Views)