This project is read-only.

Exception occurs when writing

Sep 10, 2012 at 6:38 PM
Edited Sep 11, 2012 at 3:01 PM

I'm considering using this library to write STDF files but I immediately encountered an exception in the ILGenHelpers.Ldc(this ILGenerator ilgen, object value, Type type), where type in this case is DateTime.

I'm really new to this code, but it seems that the TimeFieldLayoutAttribute is partially to blame because it has a non-null MissingValue that is not processed correctly when writing. It seems like there needs to be a Ldc_DateTime that would generate IL similar to BinaryWriter.WriteDateTime.

Here's my simple test:


List<StdfRecord> records = new List<StdfRecord>();
Far far = new Far();
far.CpuType = 2;

Mir mir = new Mir();
mir.SetupTime = DateTime.Now;
mir.StartTime = DateTime.Now;
mir.StationNumber = 3;

using (StdfFileWriter writer = new StdfFileWriter(@"D:\temp\stdftest", Endian.Little))

After additional testing I discovered other problems. Setting string fields in the MIR causes errors on writing also. In this case the problem is caused by setting the Length attribute without setting the MissingValue attribute in a StringFieldLayout:


StringFieldLayout(FieldIndex = 5, IsOptional = true, Length = 1, RecordProperty = "ProtectionCode")

I fixed this for my case by adding the MissingValue attribute:


StringFieldLayout(FieldIndex = 5, IsOptional = true, Length = 1, MissingValue = " ", RecordProperty = "ProtectionCode"),
Sep 17, 2012 at 11:06 PM

I believe the current state of the source may be slightly broken.  Paul has implemented a change in the semantics of the attributes, but the associated changes in the code generators is not yet implemented.  I'll find out the current status and try to get it back into a working state.

Feb 21, 2014 at 3:30 PM

I am evaluating LinqToStdf for doing conversion of test data into STDF format, and I came across the same issue.

Are you still planning to fix STDF 'write' bugs? Or can you perhaps recommend an older commit which is known to be better suited for writing STDF?

E.g. commit 92526d seems not affected by the above bug, but may be affected by other issues?