C# / .NET bindings for iceoryx2 - Zero-Copy Lock-Free IPC
Important
This repository is meant to be integrated into eclipse-iceoryx soon.
β Production-Ready C# Bindings!
- β Cross-platform library loading (macOS tested, Linux/Windows ready)
- β Complete P/Invoke FFI layer for all core APIs
- β Memory-safe resource management with SafeHandle pattern
- β High-level C# wrappers with builder pattern
- β Publish-Subscribe API - Full implementation with type safety and zero-copy
- β Event API - Complete notifier/listener implementation with blocking/timed waits
- β Request-Response API - Complete client/server RPC with verified FFI signatures
- β Complex Data Types - Full support for custom structs with sequential layout
- β Async/Await Support - Modern async methods for all blocking operations with CancellationToken
- β CI/CD - GitHub Actions workflow for multi-platform builds and NuGet packaging
- β Tests passing on macOS
- β Working examples for all major APIs (Pub/Sub, Event, RPC)
- β Production-ready with proper memory management and error handling
β οΈ Requires native library:libiceoryx2_ffi_c.{so|dylib|dll}(included in git submodule)
This package provides C# and .NET bindings for iceoryx2, enabling zero-copy inter-process communication in .NET applications. The bindings use P/Invoke to call into the iceoryx2 C FFI layer and provide idiomatic C# APIs with full memory safety.
- π Zero-copy IPC - Share memory between processes without serialization
- π Type-safe - Full C# type system support with compile-time checks
- π§Ή Memory-safe - Automatic resource management via SafeHandle and IDisposable
- π― Idiomatic C# - Builder pattern, Result types, LINQ-friendly APIs
- π§ Cross-platform - Works on Linux, macOS, and Windows
- π¦ Multiple patterns - Publish-Subscribe, Event, and Request-Response communication
- β‘ Async/Await - Full async support with CancellationToken for modern C# applications
dotnet add package Iceoryx2Or add to your .csproj:
<ItemGroup>
<PackageReference Include="Iceoryx2" Version="0.1.0" />
</ItemGroup>The NuGet package includes pre-built native libraries for macOS, Linux, and Windows.
Important
iceoryx2 is included as a git submodule and must be initialized and built before building the .NET project.
# Clone the repository with submodules
git clone --recursive https://github.com/eclipse-iceoryx/iceoryx2-csharp.git
cd iceoryx2-csharp
# Or if already cloned, initialize submodules
git submodule update --init --recursiveThe iceoryx2 C FFI library must be built first as the .NET project depends on it:
# From repository root
cd iceoryx2
cargo build --release --package iceoryx2-ffi-c
cd ..This creates the native library at:
- Linux:
iceoryx2/target/release/libiceoryx2_ffi_c.so - macOS:
iceoryx2/target/release/libiceoryx2_ffi_c.dylib - Windows:
iceoryx2/target/release/iceoryx2_ffi_c.dll
# From repository root
dotnet buildThe build automatically copies the native library from iceoryx2/target/release/
to the output directories.
dotnet test# Terminal 1 - Publisher
cd examples/PublishSubscribe
dotnet run -- publisher
# Terminal 2 - Subscriber
cd examples/PublishSubscribe
dotnet run -- subscriberYou should see the subscriber receiving incrementing counter values from the publisher!
- .NET 8.0 or .NET 9.0 SDK (Download)
- Rust toolchain (for building the iceoryx2 C FFI library) - Install via rustup
- C compiler and libclang (required for building iceoryx2):
- Linux:
sudo apt-get install clang libclang-dev - macOS:
brew install llvm(usually pre-installed with Xcode) - Windows: MSVC Build Tools (usually included with Visual Studio)
- Linux:
Note
The iceoryx2 project is included as a git submodule. You must initialize it before building.
# If you haven't cloned with --recursive
git submodule update --init --recursiveImportant
The iceoryx2 C FFI library must be built before the .NET project.
# From repository root
cd iceoryx2
cargo build --release --package iceoryx2-ffi-c
cd ..This creates the native library in iceoryx2/target/release/:
- Linux:
libiceoryx2_ffi_c.so - macOS:
libiceoryx2_ffi_c.dylib - Windows:
iceoryx2_ffi_c.dll
# From repository root
dotnet build --configuration ReleaseThe build process automatically:
- Copies the native library to all output directories
- Builds all projects (iceoryx2, iceoryx2.Reactive, tests, examples)
dotnet test --configuration ReleaseAll examples are built automatically with the solution. To run a specific example:
Publish-Subscribe Example:
# Terminal 1 - Run publisher
cd examples/PublishSubscribe
dotnet run -- publisher
# Terminal 2 - Run subscriber
cd examples/PublishSubscribe
dotnet run -- subscriberEvent Example:
# Terminal 1 - Run notifier
cd examples/Event
dotnet run -- notifier
# Terminal 2 - Run listener
cd examples/Event
dotnet run -- listenerA convenience build script is provided that handles all steps:
./build.shThis script:
- Builds the iceoryx2 C FFI library
- Generates C# bindings (optional)
- Builds the .NET solution
- Runs tests
- Builds examples
The C# bindings automatically detect and load the correct native library for your platform:
| Platform | Library Names (tried in order) |
|---|---|
| Linux | libiceoryx2_ffi_c.so, iceoryx2_ffi_c.so |
| macOS | libiceoryx2_ffi_c.dylib, iceoryx2_ffi_c.dylib |
| Windows | iceoryx2_ffi_c.dll, libiceoryx2_ffi_c.dll |
iceoryx2-csharp/
βββ iceoryx2/ # Git submodule - iceoryx2 Rust implementation
βββ src/
β βββ Iceoryx2/ # Main C# library
β β βββ Native/ # C-bindings via P/Invoke
β β βββ SafeHandles/ # Memory-safe resource management
β β βββ Core/ # High-level API wrappers
β β βββ PublishSubscribe/ # Pub/Sub messaging pattern
β β βββ Event/ # Event-based communication
β β βββ RequestResponse/ # Request-Response (RPC) pattern
β β βββ Types/ # Common types and utilities
β βββ Iceoryx2.Reactive/ # Reactive Extensions support
βββ examples/ # C# examples
β βββ PublishSubscribe/ # Pub/Sub example
β βββ ComplexDataTypes/ # Complex struct example
β βββ Event/ # Event API example
β βββ RequestResponse/ # Request-Response RPC example
β βββ AsyncPubSub/ # Async/await patterns example
βββ tests/ # Unit tests
βββ README.md
Detailed usage examples for different patterns (Publish-Subscribe, Event, Request-Response, etc.) can be found in examples/README.md.
Note
To run the examples, you must specify the target framework:
dotnet run --framework net9.0
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
See ROADMAP.md for the current project roadmap and future plans.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.