Passing Structs to Code Modules - .NET

Purpose

This example demonstrates how to pass a TestStand container as a .NET struct to a method in an assembly. This example uses functions to pass the struct by both reference and value. For a method in an assembly to change the value of a TestStand container, you must pass the reference of the container to the method.

Example File Location

<TestStand Public>\Examples\Fundamentals\Passing Structs to Code Modules\DotNet\Passing Structs to Code Modules.seq

Highlighted Features

  • .NET Adapter
  • Local variables
  • Data types

Major API

None

Prerequisites

None

How to Use This Example

The sequence specifies StructOut and StructIn container local variables, which you can review on the Variables pane. The sequence uses a .NET method to copy the values from the StructOut container to the StructIn container first by reference and then by value.

Complete the following steps to use this example.

  1. Select Execute»Test UUTs to run the sequence.
  2. Enter any serial number in the UUT Information dialog box and click OK. TestStand launches a Get Results dialog box that lists values loaded from the StructIn container, which specified default values before you executed the sequence.
  3. Click OK in the Get Results dialog box. TestStand launches another Get Results dialog box that lists values loaded from the StructIn container. The second GetStructByRef step specifies a pre-expression that specifies a value of 0 for each variable, and then the step specifies new values for each variable.
  4. Click OK when TestStand informs you that the sequence passed.
  5. Click Stop in the UUT Information dialog box to end the execution.

You can review the two Message Popup steps in the sequence to verify that the StructIn container is displaying the variable values. The methods the assembly is using are available in StructPassingDotNet.dll, located in the <TestStand Public>\Examples\Fundamentals\Passing Structs to Code Modules\DotNet directory.