From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

VB and NI-DAQ Card

I am running vb 2005 and I have developed software that uses a NI-DAQ card. When I build my program and install it on the same PC my VB 2005 is on I can see my NI-DAQ card in my program and everything runs well. (The VB 2005 and the installed program are both running on a windows XP Virtual Machine) when I go to install the program on my Windows 7 64 PC (which is the same PC that I am running my VM) I can;t seem to find it in my program.

My question is what would be the difference with why the VM XP machine sees the NI-DAQ card when my vb program is install and why it doesn;t see the NI-DAQ card installed on the Windows 7 64 machine.

The code is how I search and populate the combo box.


  Private Sub tmrGetDevices_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGetDevices.Tick
        Me.tmrGetDevices.Enabled = False
        Dim mainform As frmMain = Me.MdiParent
        Dim oldtstext As String = mainform.toolStripLbl1.Tex

t
        mainform.toolStripLbl1.Text = "Searching for National Instruments Cards - " & oldtstext

        Try
            If sequenceMethod.CheckIfNIExists Then
                sequenceMethod.FillIOCardsWithNI(niCards)
                boolNIExists = True
            Else
                boolNIExists = False
            End If
0 Kudos
Message 1 of 41
(5,365 Views)

Hi,

 

What DAQ card are you using? What version of DAQmx do you have on your VM and Windows 7 machine? Also, are you able to communicate with your DAQ card in MAX in Windows 7? Posting your code would be really helpful.

 

Rohama K.
0 Kudos
Message 2 of 41
(5,350 Views)

I have several calls to an external hardware NI-DAQ card. One call is the code below. When I run my program in the Debug mode I dont have any issues with finding the NI-DAQ device, however when I build the program and run it on another machine I seem to get error or the code below doesn;t execute. I believe it may be my program references or dependencies so I have attached screen shots of both. My question is what am I doing wrong?

 

I am working with the NI USB 6525. Also it fails on the Function CheckIfNIExists() and the error is the following:

 

 

Error Information
    Partfile Name = 4.2.0.0
    Error Target - CheckIfNIExists
    Error Message - Could not load file or assembly 'NationalInstruments.DAQmx, Version=9.5.20.112, Culture=neutral, PublicKeyToken=4544464cdeaab541' or one of its dependencies. An attempt was made to load a program with an incorrect format.
    Exception Type - System.BadImageFormatException: Could not load file or assembly 'NationalInstruments.DAQmx, Version=9.5.20.112, Culture=neutral, PublicKeyToken=4544464cdeaab541' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'NationalInstruments.DAQmx, Version=9.5.20.112, Culture=neutral, PublicKeyToken=4544464cdeaab541'
   at LMIObjectLibrary.SequenceMethods.CheckIfNIExists()
   at UGI.frmSequenceEditor2.tmrGetDevices_Tick(Object sender, EventArgs e)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace
       at LMIObjectLibrary.SequenceMethods.CheckIfNIExists()
   at UGI.frmSequenceEditor2.tmrGetDevices_Tick(Object sender, EventArgs e)

 

 

 

Imports NationalInstruments.DAQmx

Imports NationalInstruments

 

 Private Sub tmrGetDevices_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGetDevices.Tick
        Me.tmrGetDevices.Enabled = False
        Dim mainform As frmMain = Me.MdiParent
        Dim oldtstext As String = mainform.toolStripLbl1.Text
        mainform.toolStripLbl1.Text = "Searching for National Instruments Cards - " & oldtstext

        Try
            MessageBox.Show("In Timer")
            If sequenceMethod.CheckIfNIExists Then
                sequenceMethod.FillIOCardsWithNI(niCards)
                boolNIExists = True
                MessageBox.Show("Card Found")
            Else
                boolNIExists = False
            End If
        Catch ex As Exception
            boolNIExists = False
            'MessageBox.Show("Card Not Found")
            _TListener.AddMethodError(ex)
        End Try
        mainform.toolStripLbl1.Text = oldtstext
        mainform = Nothing
    End Sub

 

 

Public Function CheckIfNIExists() As Boolean
        Try
            MessageBox.Show("Inside CheckIfNIExists")
            Dim tmpDevices() As String = DaqSystem.Local.Devices
            Return True
        Catch fnfex As FileNotFoundException
            Return False
        Catch ex As Exception
            ' Return False
            tlistener.AddMethodError(ex)
        End Try
    End Function

0 Kudos
Message 3 of 41
(5,348 Views)

This may have to do with the version of DAQmx you have on both machines. What versions do you have? Are you able to run the code in debug mode on your Windows 7 machine?

Rohama K.
0 Kudos
Message 4 of 41
(5,343 Views)

I am able to run the program and also debug and run the program under the VM XP Pro SP3 machine is where my VS environment is... I look under the add /remove programs on both the VM machine and the Windows 7 64 bit machine and 9.5.0. As for anything else and version number I do not know where to look.

0 Kudos
Message 5 of 41
(5,341 Views)

When you build your executable, what is your target platform set to? Chances are it is set to "Any CPU". Try setting it to x86, build it and then run it on your Windows 7 machine. This will force it to run in 32-bit mode on a 64-bit machine.

Rohama K.
0 Kudos
Message 6 of 41
(5,337 Views)

OK I do have a lot of other 3rd party software that aren;t giving any errors when I run them on Windows 7 PC.

 

I did change the x86 plateform and no change still the same error on the Window 7 64 bit machine. I did however try the same (build before the Plateform change on another Windows XP SP3 machine and it gave me the same error.

 

It is definatly driver related I just dont know where to look.

 

 

0 Kudos
Message 7 of 41
(5,335 Views)

How about you build an installer instead and that way, all needed files are installed on to the machine that tries to run the executable. 

Rohama K.
0 Kudos
Message 8 of 41
(5,333 Views)

I could if I knew how...however I do not want to change anything major on the load. Do you have any idead how I can compare the error I am seeing on the Windows 7/XP and which drivers are different from the other Windows XP machine?

 

 Error Message - Could not load file or assembly 'NationalInstruments.DAQmx, Version=9.5.20.112, Culture=neutral, PublicKeyToken=4544464cdeaab541' or one of its dependencies. An attempt was made to load a program with an incorrect format.
    Exception Type - System.BadImageFormatException: Could not load file or assembly 'NationalInstruments.DAQmx, Version=9.5.20.112, Culture=neutral, PublicKeyToken=4544464cdeaab541' or one of its dependencies. An attempt was made to load a program with an incorrect format.

0 Kudos
Message 9 of 41
(5,331 Views)

In Measurement & Automation Explorer, create a technical report. This KB has detailed instructions on how to do that. Do this for both VM and Windows 7 machine. Attach the reports and I will take a look at them.

Rohama K.
0 Kudos
Message 10 of 41
(5,328 Views)