The FrontPanel SDK can be used from C# through two APIs:

  • Binding API (OpalKelly.FrontPanel) — mirrors the C++ FrontPanel SDK, so its names match the C++ API reference and examples. Stable and complete.
  • Idiomatic API (OpalKelly.FrontPanel.Api) — a modern, idiomatic .NET interface that mirrors the FrontPanel Platform (TypeScript) API: Device and DeviceManager objects, IDisposable/using for cleanup, exceptions, and PascalCase names.

Beta: the Idiomatic API is new and its surface may change in future releases.

The C# assemblies and NuGet package are in the SDK’s API\Csharp folder. C# support is Windows-only, on x64 or ARM64, and targets .NET Framework 4.8 or modern .NET (.NET 5 or later).

Which should I use?

  • Choose the Idiomatic API if you are writing new C# code and want the most natural, idiomatic .NET experience.
  • Choose the Binding API if you are migrating an existing FrontPanel application, or following the C++ API reference and examples.

The Idiomatic API is built on the Binding API, and the NuGet package below includes both.

Using the Idiomatic API

The Idiomatic API is provided as the OpalKelly.FrontPanel.Api NuGet package in the SDK’s API\Csharp folder. It is not published to nuget.org, so add that folder as a NuGet package source and then install the package into your project — for example, using the NuGet Package Manager in Visual Studio. The package bundles the native FrontPanel libraries it needs, so there is nothing else to set up.

For how to add a package source and install a package, see the Visual Studio or .NET documentation.

Example Syntax

This opens the first available device, reads its identity, loads an FPGA configuration, and then uses the classic data port to set a wire and fire a trigger.

using OpalKelly.FrontPanel.Api;

// Open the first available device; the `using` block closes it automatically.
using (Device device = new DeviceManager().OpenDevice())
{
    DeviceInfo info = device.GetDeviceInfo();
    Console.WriteLine($"Serial:  {info.SerialNumber}");
    Console.WriteLine($"Product: {info.ProductName}");

    // Load your FPGA configuration before using the data port.
    device.GetFpgaConfiguration().LoadConfigurationFromFile("my_design.bit");

    // Wires, triggers, and pipes live on the classic data port.
    using (FpgaDataPortClassic classic = device.GetFpgaDataPortClassic())
    {
        // Set a wire-in value and send it to the device.
        classic.SetWireInValue(0x00, 0x01);
        classic.UpdateWireIns();

        // Fire a trigger-in (endpoint 0x40, bit 0).
        classic.ActivateTriggerIn(0x40, 0);
    }
}Code language: C# (cs)
  • new DeviceManager().OpenDevice() opens the first available device and returns a Device; the using block closes it when you leave the block.
  • GetFpgaConfiguration().LoadConfigurationFromFile() loads your FPGA configuration (a .bit file).
  • GetFpgaDataPortClassic() returns the classic data port for wires, triggers, and pipes.
  • SetWireInValue() then UpdateWireIns() set a wire and send it; ActivateTriggerIn() fires a trigger.

Using the Binding API

The C# Binding API is built as an extension library using the Platform Invoke (PInvoke) capability of .NET. The C# DLL is targeted for Any CPU, meaning it will run as a 32-bit process in 32-bit applications, and as a 64-bit process in 64-bit applications. You can read more about this here.

The Binding API mirrors the C++ FrontPanel SDK (okCFrontPanel and related classes). Get it from the NuGet package, or reference the assembly directly.

NuGet package

If you installed the OpalKelly.FrontPanel.Api package (see above), the Binding API is already included — just import its namespace:

using OpalKelly.FrontPanel;Code language: C# (cs)

Required files (manual reference)

If you are not using NuGet, reference the Binding API assembly directly and make the native libraries available to your application. From the SDK’s API\Csharp folder:

  • libFrontPanel-csharp.dll — the managed assembly; add it as a project reference.
  • libFrontPanel-pinv.dll — native P/Invoke library; place it in your application’s runtime directory.
  • okFrontPanel.dll — native FrontPanel library; place it in your application’s runtime directory.
  • okimpl_fpoip.dll — optional; add it for FrontPanel-over-IP support.
using OpalKelly.FrontPanel;Code language: C# (cs)

Example Syntax

This opens the first available device, loads an FPGA configuration, and then uses the classic data port to set a wire and fire a trigger.

using OpalKelly.FrontPanel;

// Open the first available device.
okCFrontPanel device = new okCFrontPanelDevices().Open();

// Load your FPGA configuration before using the data port.
device.ConfigureFPGA("my_design.bit");

// Wires, triggers, and pipes live on the classic data port.
okCFPGADataPortClassic classic = device.GetFPGADataPortClassic();

// Set a wire-in value and send it to the device.
classic.SetWireInValue(0x00, 0x01);
classic.UpdateWireIns();

// Fire a trigger-in (endpoint 0x40, bit 0).
classic.ActivateTriggerIn(0x40, 0);Code language: C# (cs)
  • new okCFrontPanelDevices().Open() opens the first available device.
  • ConfigureFPGA() loads your FPGA configuration (a .bit file) onto the device.
  • GetFPGADataPortClassic() returns the classic data port, which carries wires, triggers, and pipes.
  • SetWireInValue() then UpdateWireIns() set a wire and send it; ActivateTriggerIn() fires a trigger.

Next steps

  • Migrating from FrontPanel 5.x? See the C# migration guide.
  • How-to guides walk through common tasks — enumerating devices, configuring the FPGA, transferring data, and more — with examples in both APIs.
  • Reference for the Idiomatic API: the FrontPanel Platform API, which it mirrors — synchronous and PascalCase for C#, asynchronous (Promises) and camelCase for Typescript.
  • Reference for the Binding API: the C++ API reference, which it mirrors name-for-name.