Hi Volvick,
Before accessing the TextFormat property, did you check whether the myRectangle.Style is not null and whether the myRectangle.Style.TextStyle is not null?
In general you should use the following code to safely assign a text style to a stylable element.
// create new text style
NTextStyle textStyle = new NTextStyle();
textStyle.TextFormat = TextFormat.XML;
// safely set it to a styleable element
NStyle.SetTextStyle(myRectangle, textStyle);
As all static style setters, defined by the NStyle class, this method will internally check whether the style of the element is created and create it if it is not already created.
Best Regards,
Nevron Support Team