The size of user strings has to be correct. structs with the attribute [String] have to fulfill:
- if the second parameter in the String attribute is true (e.g.
[String(<value>, true]) the string is a wide string, therefore:- the
Sizeparameter of theStructLayoutattribute has to be 6 greater than the first parameter (size) of the[String]attribute multiplicated by 2. ([StructLayout(LayoutKind.Explicit, Size = <2*value+6>)]) - the
m_capof the string'sIecWStringfield (set inInit()) has to be equal to the first parameter (size) of the[String]attribute.
- the
- else
- the
Sizeparameter of theStructLayoutattribute has to be 6 greater than the first parameter (size) of the[String]attribute. ([StructLayout(LayoutKind.Explicit, Size = <value+6>)]) - the
maximumLengthof the string'sIecStringExfield (set inInit()) has to be equal to the first parameter (size) of the[String]attribute.
- the
Also see the [String] pattern Iec026 asks for.
You can also view an explanation and example of a string implementation on Gitub
You can also use the provided automatic Code Fix to adjust the sizes to the definition in the [String] attribute. ( Press Alt + Enter on the Error line to find the Code Fix in the context menu)
Assign the size defined in the [String] attribute to the IecStringEx/IecWString field. Set it (multiplicated with 2 for wide strings and) increased by 6 as the [StructLayout] attribute's Size parameter.
