Rockwell Automation’s FactoryTalk Optix provides access to the broad development capabilities of the .NET framework, giving developers greater flexibility when building SCADA systems and middleware applications. This blog covers the essentials of .NET integration in Optix and how you can use it to extend your applications.
.NET Solution in Optix
The Optix NetSolution is a browsable C# project that contains the custom code (NetLogic) used by the project. The NetSolution files can be found in the ProjectFiles folder in the Optix Studio project. NetLogic scripts can be created and accessed through the Optix Studio project view, as shown below.

UA Nodes and the Information Model
Optix follows the OPC/UA-specified nodal architecture, which is generally represented through the information model. Each node carries a series of attributes which describe the node’s properties. The .NET solution scripts access and interface with Optix Studio project elements (“nodes”) at both DesignTime and Runtime through these information model attributes, specifically, the NodeId and the BrowseName. For more details on the Optix information model implementation, see the NetLogic cheat sheet, found in References.
Accessing Optix Studio Objects from NetLogic
The following example shows one efficient way to access Optix objects within NetLogic scripts: utilizing the ability to create child variables on parent nodes in the Optix Studio UI. Suppose you need access to the information held in a motor model object for the NetLogic script, DoThingsUsingTheMotor. To access the motor object through the information model, you can link its node ID to the child variable of the NetLogic object.
First, on the script object in Studio, create a variable.

Next, click “int32” to bring up the data type editor, and select “Show All” to browse all data types.

Find the NodeId data type and hit “Select.” Rename the variable to “MotorNode.”

Next, select the dynamic link button.

Find the motor in the project and hit “Select.”

Now, on the LogicObject associated with the NetLogic, this variable can be accessed. The script shown below does the following:
- Accesses the LogicObject variable containing the NodeId of the motor
- Accesses the Motor using the Information Model
- Accesses the Sts_MotorActive variable and prints its value to the Log.


Runtime NetLogic
The C# methods that execute during a project’s runtime are called runtime NetLogic. Runtime NetLogic can accomplish a variety of tasks, like database querying, PLC reads/writes, reporting, etc.
The Runtime NetLogic can be run as standalone scripts or used to build out a full backend .NET application, depending on the needs of the project.
Runtime NetLogic Components
The C# methods that execute during a project’s runtime are called Runtime NetLogic. Runtime NetLogic can accomplish a variety of tasks, like database querying, PLC reads/writes, reporting, etc.
You can run Runtime NetLogic as standalone scripts or use it to build a full backend .NET application, depending on the project’s needs.
Start and Stop Methods
By default, Runtime NetLogic scripts include Start and Stop methods, which run on node activation and deactivation, essentially at project startup and shutdown. The start method is intended for fast startup actions like class initializations and task creation. All Start (and Stop) functions run sequentially, so running slower actions in these methods can significantly delay other Start functions.
More information is available in the FT Optix NetLogic cheat sheet, found in References.
Export Methods
Export methods are the public methods that are viewable from the Optix UI and callable from events handled by the Optix project, such as variable changes, mouse inputs, or user logins.
In the following example, we create an export method that executes a SQL query on a variable tag change. To create an Export Method, right-click the NetLogic in the Optix UI and select New > Method, as shown below.

This will open the NetLogic and automatically create a method with the [ExportMethod] header.

Note: Always create Export Methods through the Optix UI. Export Methods that are manually added to the script may not be recognized immediately.
From here, you can rename the Export Method and add parameters to it.

From this method, you can manipulate just about anything in the Optix project. The example script below takes in a “Message” variable on the motor node and logs this message to an embedded SQL database when the method is called.

Now, the export method can be called based on a “Command” variable reading True. Right-click the “Command” variable and create a transition event. Set the target value to 1.

Hit the “+” and locate the export method you want to call.

Set the inputs to the function, in this case the motor object node, so we can access the motor object variables.

Now, the method to add the message as an entry to the embedded database will be triggered every time the command transitions to 1.

Having trouble getting an Export Method to register in the Optix UI?
If you add a new Export Method (especially if other changes are made to the NetLogix file) and do not immediately see it in the Optix UI, try the following steps:
- Make a fresh NetLogic script through the Studio UI.
- Make a new Export Method through the Studio UI.
- Rename the Export Method and add the input parameters. Do not add anything to the method body. Save the script, close the script, and save the Studio project.
- Re-open the script and add the remaining code. Do not paste over the class declaration or the start/stop declarations; only edit them individually as needed.
- Save and close the script. Save the Studio project. The Export Method should now be available to call under any Event.
DesignTime NetLogic
DesignTime NetLogic is the name for C# scripts that can be executed on the Optix project from the studio UI while working on project design. For example, design time can be used for creating/changing large numbers of dynamic links, propagating objects, making UI changes, etc. DesignTime NetLogic scripts are created and stored in the “NetLogic” folder in the studio UI, and are executed by right-clicking the NetLogic folder and selecting “Execute [Script name]”
As an example, the following code is used to automatically create a set of “Process Order” objects. You can interact with the information model at design time, which makes this a much more efficient way to create these objects (rather than adding each one manually).

Tips:
- It’s a good idea to take a backup of the project before developing and running DesignTime scripts.
- In my use of DesignTime, I have found that it is easiest to access nodes in the information model based on the BrowsePath as opposed to the NodeId.
- After running DesignTime scripts, the NetSolution may occasionally fail to build, citing errors to do with the Microsoft packages. This can be resolved by saving, closing the project, reopening the project, and saving again.
Task Handling
When creating more complex NetLogic codebases/backend C# applications, it is crucial to properly handle tasks to avoid Optix performance issues. In place of standard C# async/await functions, Optix provides a set of recommended task handlers.
Long Running Tasks
For custom single-fire async applications, Rockwell recommends that the Optix LongRunningTask class be used. This allows cancellable tasks to be run without blocking the operation of the main code.
An example of a LongRunningTask implementation to listen for TCP messages from a scanner is shown outlined below. At project startup, information model data is passed into a LongRunningTask to establish the listener.

The LongRunningTask instance calls a method that establishes a TCP listener that is active for the duration of the project’s runtime.

Upon project shutdown, the CancellationToken is used to cancel and dispose of the LongRunningTask.

Other Tasking
Optix also provides support for periodic and delayed tasking. See the NetLogic cheat sheet for more information.
Optix Built-in Script Library
The Optix Library includes a useful set of DesignTime and Runtime NetLogic scripts, including information exporters, project analyzers, and useful generic scripts.
To access the script library, find the library icon in the heading bar and select the script library in the pop-up. Each script includes a description and setup instructions.

Other Miscellaneous Tips
.NET Solution Failed to Build – MS Dependency Injection
When two different Windows users open the same Optix project on a shared machine at different times and the “Microsoft.dependencyinjection.abstractions” package is being used in the project, the .NET solution may fail to build, citing this package. To resolve this, try the following steps:
- On the user login that reports the error, close Optix.
- Locate the MS dependency injection folder (or whichever package is referenced in the .NET Solution failed to build error) and move the folder out of the project. In my case, the “8.0.2” folder was causing the problem.
- Once the file is moved out of the project, open Optix Studio and verify that the .NET Solution builds.
- Save the Optix project, then close Optix Studio.
- Add the problematic folder back to its original location, open Optix Studio, and save. The NetSolution should now build.

Key Takeaways
Backend organization is a small, often-forgotten component of automating manufacturing workflows. From simple C# scripting to integrating full .NET applications, FactoryTalk Optix’s .NET support provides a powerful foundation for building adaptable, customized solutions.
The key is understanding how the pieces fit together. Once you’re familiar with the NetSolution, NetLogic, and Optix information model, C# becomes another tool for extending your application. You can build reusable functionality, interface with project nodes at runtime, and connect your Optix application to functionality available through .NET.
For developers already familiar with C#, this also provides a familiar path for bringing established programming practices into an industrial application. The result is greater flexibility to build around the needs of the machine, process, or larger automation architecture.
Ready to learn more about a custom automation solution? DMC can help.
Whether you’re exploring FactoryTalk Optix or need help integrating it into a larger system, contact DMC to discuss your next automation project.







