Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

TdmsProperty throws InvalidOperationException

Solved!
Go to solution

Hey all,

 

I have the following line of code  that's throwing an InvalidOperationException

 

 

TdmsProperty SampFreq =
                        new TdmsProperty(m_SampleFreq, TdmsPropertyDataType.Double, temp[2]);

 

I've verified that I'm calling the constructor correctly and it matches up with the convention shown in the TDMS API tutorial NI provides.  The additional error message provided with the Exception Helper in VS.NET is:

 

The type parameter of the method does not match the data type of the TDMS property.

 

This makes very little sense to me.  Is there another Type I'm supposed to use for this constructor?  This is my first time using this API and the error is inconsistent with the documentation I've been able to find.

 

Thanks.

0 Kudos
Message 1 of 3
(3,744 Views)
Solution
Accepted by topic author nowellj

Hello nowellj,

 

This exception occurs when the third parameter is of a different data type than was is specified in the second parameter.  What is the data type of your variable temp?  If it is not an array of doubles, you will get the exception you reported.  I tested your code snippet as follows, and did not see any exception:

 

double[] temp = new double[] { 12.4d, 5.4d, 6.5d, 8.6d };
TdmsProperty prop = new TdmsProperty("SomeDoubleNum", TdmsPropertyDataType.Double, temp[2]);

 

 

Is this similar to what you are doing? 

 

NickB

National Instruments 

Message 2 of 3
(3,720 Views)
Thanks.  What you can't see, and what I forgot to keep track of is that I'm reading in the properties from a text file and breaking each line apart.  I simply forgot to parse the string to the correct data type.  I got too sidetracked to see it before.
0 Kudos
Message 3 of 3
(3,717 Views)