C# & .NET

TIA Portal in C#, finally simple.

Build C#/.NET applications that interact with TIA Portal without the complications of the native SDK. T-IA Connect offers a REST API or modern C# client with async/await.

The Challenge

The TIA Openness SDK is complex

Using TIA Portal from C# with the native SDK requires lots of boilerplate code and deep knowledge of the Siemens architecture.

DLL References

Each TIA Portal version has its own DLLs. Managing references and versions is tedious.

STA Threading

TIA Openness requires an STA thread. Incompatible with modern async/await patterns.

Verbose Code

Navigating the project tree, type casting, transaction handling... Lots of code for little value.

No NuGet

No official NuGet package. Manual DLL installation on every development machine.

The Solution

Two approaches for C#/.NET

T-IA Connect offers two ways to integrate TIA Portal into your C# applications: a universal REST API or a native C# client.

REST API

Use standard HttpClient to call the T-IA Connect API. Works with .NET Core, .NET 5+, .NET Framework.

// .NET with HttpClient
using var client = new HttpClient();
var response = await client.PostAsJsonAsync(
    "http://localhost:5000/api/blocks",
    new { name = "FC_Motor", type = "FC", language = "SCL" }
);
var block = await response.Content.ReadFromJsonAsync<Block>();

Native C# Client

NuGet package with full IntelliSense, strongly-typed types and async/await patterns.

// T-IA Connect C# Client
using TiaConnect.Client;

var client = new TiaConnectClient("http://localhost:5000");

// Create a block with IntelliSense
var block = await client.Blocks.CreateAsync(new CreateBlockRequest
{
    Name = "FC_Motor",
    Type = BlockType.FC,
    Language = ProgrammingLanguage.SCL
});

Console.WriteLine($"Block created: {block.Name} (#{block.Number})");
Benefits

Why T-IA Connect for C#

Native Async/Await

All methods are asynchronous. Perfect for UI applications and web services.

Full IntelliSense

XML documentation, strongly-typed types, autocompletion. Maximum productivity in Visual Studio.

NuGet Package

One-command installation: dotnet add package TiaConnect.Client. Automatic updates.

Modern .NET

Compatible with .NET 6, 7, 8 and .NET Framework 4.7.2+. Use the latest C# features.

Code Comparison

Native TIA Openness
// Native TIA Openness - STA thread required
[STAThread]
static void Main()
{
    using (TiaPortal portal = new TiaPortal(TiaPortalMode.WithUserInterface))
    {
        Project project = portal.Projects.Open(new FileInfo(path));
        
        foreach (Device device in project.Devices)
        {
            DeviceItem cpu = device.DeviceItems
                .FirstOrDefault(di => di.GetService<SoftwareContainer>() != null);
            
            if (cpu != null)
            {
                var sw = cpu.GetService<SoftwareContainer>();
                var plc = sw.Software as PlcSoftware;
                var blocks = plc.BlockGroup.Blocks;
                
                // Create a block
                PlcBlock fc = blocks.CreateFC("FC_Motor");
            }
        }
    }
}
T-IA Connect C#
// T-IA Connect - Modern async
using TiaConnect.Client;

var client = new TiaConnectClient("http://localhost:5000");

// Open project
var project = await client.Projects.OpenAsync("C:/Projects/MyProject.ap18");

// Create an FC block
var block = await client.Blocks.CreateAsync(new CreateBlockRequest
{
    Name = "FC_Motor",
    Type = BlockType.FC,
    Language = ProgrammingLanguage.SCL,
    Comment = "Main motor control"
});

Console.WriteLine($"Created: {block.Name}");

Ready to simplify your C# code?

Try the T-IA Connect API and discover a new way to program TIA Portal.