Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

type initializer for 'NationalInstruments.PrecisionWaveformTiming' threw an exception

Hi,

I try to scan three channels (ai0-2) with a PCIe-6361 card on a Windows XP SP3 PC with Visual Studio 2010 Prof and .Net-Framework 4.The exception occurs when I call the line:

data = reader.ReadWaveform(Anzahl_Werte_per_Chan)

 

It is the same, when I try to scan only one channel, so it looks like a general thing.

 

Any idea? Any help? Thanks a lot!

 

Axel

 


error message says:

"The type initializer for 'NationalInstruments.PrecisionWaveformTiming' threw an exception."


Code is:


sampleRate = 300000
Kanal1 = "Dev1/ai0"
Kanal2 = "Dev1/ai1"
Kanal3 = "Dev1/ai2"
Anzahl_Werte_per_Chan = 100000


    
    Sub Sample_3_Channels(Soll_SampleRate As Double, ByRef Ist_Samplerate As Double, Kanal1 As Integer, Kanal2 As Integer, Kanal3 As Integer, Anzahl_Werte_per_Chan As Int32, ByRef Messwertfeld_1() As Double, ByRef Messwertfeld_2() As Double, ByRef Messwertfeld_3() As Double, ByRef Errnum As Integer)
        Dim Device_String As String

        Errnum = 0

        If gOhne_NI = True Then Exit Sub

        Try
            ' Create a new task
            myTask = New Task()

            Device_String = ""
            Device_String = "Dev" & Format(gNI_Device, "0") & "/ai" & Format(Kanal1) & ","
            Device_String = Device_String & "Dev" & Format(gNI_Device, "0") & "/ai" & Format(Kanal2) & ","
            Device_String = Device_String & "Dev" & Format(gNI_Device, "0") & "/ai" & Format(Kanal3) & ","

            ' Create a channel
            myTask.AIChannels.CreateVoltageChannel(Device_String, "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)

            ' Configure timing specs
            myTask.Timing.ConfigureSampleClock("", Soll_SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Anzahl_Werte_per_Chan)

            ' Verify the task
            myTask.Control(TaskAction.Verify)

            Ist_Samplerate = myTask.Timing.AIConvertRate / 3.0
            reader = New AnalogMultiChannelReader(myTask.Stream)

            ' Read the data
            Dim data() As AnalogWaveform(Of Double)
            data = reader.ReadWaveform(Anzahl_Werte_per_Chan)


            'For Each waveform As AnalogWaveform(Of Double) In data
            Dim dataCount As Integer = 0
            dataCount = data(0).Samples.Count
            ReDim Messwertfeld_1(0 To (dataCount - 1))
            For sample As Integer = 0 To (dataCount - 1)
                Messwertfeld_1(sample) = (data(0).Samples(sample).Value * g_AI(Kanal1).Gain - g_AI(Kanal1).offset)
            Next

            dataCount = data(1).Samples.Count
            ReDim Messwertfeld_2(0 To (dataCount - 1))
            For sample As Integer = 0 To (dataCount - 1)
                Messwertfeld_2(sample) = (data(1).Samples(sample).Value * g_AI(Kanal2).Gain - g_AI(Kanal2).offset)
            Next

            dataCount = data(2).Samples.Count
            ReDim Messwertfeld_3(0 To (dataCount - 1))
            For sample As Integer = 0 To (dataCount - 1)
                Messwertfeld_3(sample) = (data(2).Samples(sample).Value * g_AI(Kanal3).Gain - g_AI(Kanal3).offset)
            Next


        Catch dex As DaqException
            FehlerLog(True, dex)
            Errnum = -1
        Catch ex As Exception
            FehlerLog(True, ex)
            Errnum = -1
        Finally
            myTask.Dispose()
        End Try

0 Kudos
Message 1 of 5
(3,589 Views)

Hi,

 

I forgot: NI-DAQmx Version 9.4.0.f5. Meanwhile I believe that the project references are not correct or the DAQmx driver is not installed correct (or a part is missing).

 

Any idea? Thanks in advance!

 

Axel

0 Kudos
Message 2 of 5
(3,584 Views)

Hi Axel,

 

Where does this error occur?

On your development pc or is it an application?

 

Have you already tried this Knowledge Base?

 

System.TypeInitializationException Error When Loading a Deployed Measurement Studio Analysis Application

http://digital.ni.com/public.nsf/allkb/70648C253C7155FD862570ED005EA94E?OpenDocument

 

0 Kudos
Message 3 of 5
(3,572 Views)

Hi ZwJoh,

 

thanks for your answer. Meanwhile I found a similar possibility. I think the custumer doesn't install the files for the .Net Framework 4, he simply choose "typical installation". So I tried to modify the installation, but the installer showed an error message (see attached file). I didn't find a way to get the installation work and the error occurs for all kinds of .Net Framework versions. Any idea what to do?

Thanks in advance for any hint!

 

Axel

0 Kudos
Message 4 of 5
(3,560 Views)

Hi ZwJoh and all others, 

 

I have the same problem on the developer system as on machine. But I did a mistake. I tried to install the complete .Net Framework 4 support. On my system it was enough to install only the support without the sub-features. Maybe that solves everything?

Thanks for any help anyway.

 

Axel

0 Kudos
Message 5 of 5
(3,556 Views)