OpcSharp.Tool
0.3.1
dotnet tool install --global OpcSharp.Tool --version 0.3.1
dotnet new tool-manifest
dotnet tool install --local OpcSharp.Tool --version 0.3.1
#tool dotnet:?package=OpcSharp.Tool&version=0.3.1
nuke :add-package OpcSharp.Tool --version 0.3.1
OpcSharp
A pure C# OPC UA client SDK with zero external OPC UA dependencies. Implements the OPC UA Binary Protocol from scratch.
Documentation: patdhlk.com/OpcSharp
Targets: netstandard2.0 · net8.0 · net9.0 · net10.0
Installation
dotnet add package OpcSharp.Client
Individual layers can be referenced separately if needed:
dotnet add package OpcSharp.Types
dotnet add package OpcSharp.Encoding
dotnet add package OpcSharp.Transport
dotnet add package OpcSharp.Transport.Http
dotnet add package OpcSharp.Transport.WebSocket
dotnet add package OpcSharp.Security
dotnet add package OpcSharp.Protocol
dotnet add package OpcSharp.Services
Architecture
Layered stack where each layer depends only on layers below it:
OpcSharp.Client ← High-level API, fluent builder, DI integration
OpcSharp.Services ← Attribute, Browse, Method, Subscription, Discovery
OpcSharp.Protocol ← Session + SecureChannel management
OpcSharp.Security ← Security policies, crypto, certificates, user identity
OpcSharp.Transport.WebSocket ← WebSocket transport (opc.wss://, opc.ws://)
OpcSharp.Transport.Http← HTTPS transport
OpcSharp.Transport ← TCP transport, Hello/ACK, chunking
OpcSharp.Encoding ← Binary encoder/decoder for all OPC UA types
OpcSharp.Types ← NodeId, StatusCode, DataValue, Variant, etc.
Quick Start
var client = new OpcSharpClientBuilder()
.WithEndpoint("opc.tcp://localhost:4840")
.Build();
await client.ConnectAsync();
var results = await client.ReadAsync(new[]
{
new ReadValueId
{
NodeId = new NodeId(0, 2258),
AttributeId = AttributeIds.Value
}
});
Console.WriteLine(results[0].Value);
await client.DisconnectAsync();
Connect via WebSocket
Use opc.wss:// for secure WebSocket or opc.ws:// for plain WebSocket — the same API works across all transports:
var client = new OpcSharpClientBuilder()
.WithEndpoint("opc.wss://server.example.com/opcua")
.Build();
await client.ConnectAsync();
// Read, Write, Browse, Subscribe — identical to TCP
Security
Supported policies: None, Basic128Rsa15, Basic256, Basic256Sha256, Aes128_Sha256_RsaOaep, Aes256_Sha256_RsaPss, and ECC policies (NET8+).
User identity: Anonymous, UserName/Password, X509 Certificate, Issued Token (SAML/JWT).
CLI Tool
Explore and diagnose OPC UA servers from the command line:
dotnet tool install -g OpcSharp.Tool
opcsharp discover opc.tcp://localhost:4840
opcsharp browse opc.tcp://localhost:4840
opcsharp read opc.tcp://localhost:4840 -n "i=2258"
opcsharp health opc.tcp://localhost:4840
See the CLI documentation for the full command reference.
Build & Test
dotnet build OpcSharp.sln
dotnet test OpcSharp.sln
Integration tests require Docker:
docker compose -f docker/docker-compose.yml up -d --build
dotnet test tests/OpcSharp.Integration.Tests
License
See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.