The samples in this repository are hosted by the OPC Foundation to keep the sample code available for the community.
However, to avoid internal competition with OPC members that offer commercial SDKs, the OPC Foundation limits its own resources for maintenance and support to a minimum.
Contributions of the community to improve and maintain the samples and to help with issues to keep this repository alive are very welcome.
Please follow the steps outlined here to start contributing.
Sample Servers and Clients, including all required controls, for .NET Framework 4.6.2, .NET Core 2.0 and UWP.
Integrates the offical OPC UA NuGet package containing the OPC UA reference implementation targeting .NET Standard.
.Net Standard allows you develop apps that run on all common platforms available today, including Linux, iOS, Android (via Xamarin) and Windows 7/8/8.1/10 (including embedded/IoT editions) without requiring platform-specific modifications. Furthermore, cloud applications and services (such as ASP.Net, DNX, Azure Websites, Azure Webjobs, Azure Nano Server and Azure Service Fabric) are also supported.
All the tools you need for .Net Standard come with the .Net Core tools. See here for what you need.
Since Nuget version 1.4.363.107 there is support for symbol snupkg packages on Nuget.Org and github source link.
All required application certificates for OPC UA are created at the first start of each application in a directory or OS-level certificate store and remain in use until deleted from the store.
By default the self signed certificates are stored in a X509Store called CurrentUser\UA_MachineDefault. The certificates can be viewed or deleted with the Windows Certificate Management Console (certmgr.msc). The trusted, issuer and rejected stores remain in a folder called OPC Foundation\CertificateStores with a root folder which is specified by the SpecialFolder
variable %CommonApplicationData%. On Windows 7/8/8.1/10 this is usually the invisible folder C:\ProgramData.
Note: Since the sample applications in the UA-.Net repository use the same storage and application names as UA-.NetStandard, but create only certificates with hostname localhost
, it is recommended to delete all existing certificates in MachineDefault to recreate proper certificates for all sample applications when moving to the UA-.NetStandard repository.
By default the self signed certificates are stored in a X509Store called CurrentUser\UA_MachineDefault. The certificates can be viewed or deleted with the Windows Certificate Management Console (certmgr.msc).
The trusted, issuer and rejected stores remain in a folder called OPC Foundation\CertificateStores in the LocalState folder of the installed universal windows package. Deleting the application state also deletes the certificate stores.
The self signed certificates are stored in a folder called OPC Foundation/CertificateStores/MachineDefault with a root folder which is specified by the SpecialFolder
variable %LocalApplicationData% or in a X509Store called CurrentUser\My, depending on the configuration. For best cross platform support the personal store CurrentUser\My was chosen to support all platforms with the same configuration. Some platforms, like macOS, do not support arbitrary certificate stores.
The trusted, issuer and rejected stores remain in a shared folder called OPC Foundation\CertificateStores with a root folder specified by the SpecialFolder
variable %LocalApplicationData%. Depending on the target platform, this folder maps to a hidden locations under the user home directory.
By default all sample applications are configured to register with a Local Discovery Server (LDS). A reference implementation of a LDS for Windows can be downloaded here. To setup trust with the LDS the certificates need to be exchanged or registration will fail.
Startup Project
.F5
to build and execute the sample.This section describes how to run the NetCoreConsoleClient and NetCoreConsoleServer sample applications.
Please follow instructions in this article to setup the dotnet command line environment for your platform. As of today .Net Standard 2.0 is required.
dotnet
command is available, navigate to the root folder in your local copy of the repository and execute dotnet restore UA Sample Applications.sln
. This command calls into NuGet to restore the tree of dependencies.dotnet run --project NetCoreConsoleServer.csproj -a
.
-a
flag allows to auto accept unknown certificates and should only be used to simplify testing.dotnet run --project NetCoreConsoleClient.csproj -a
to connect to the OPC UA console sample server running on the same host.
-a
flag allows to auto accept unknown certificates and should only be used to simplify testing. dotnet run --project NetCoreConsoleClient.csproj -a opc.tcp://myserver:51210/UA/SampleServer
. -a
auto accept option, on first connection, or after certificates were renewed, the server may have refused the client certificate. Check the server and client folder %LocalApplicationData%/OPC Foundation/CertificateStores/RejectedCertificates for rejected certificates. To approve a certificate copy it to the %LocalApplicationData%/OPC Foundation/CertificateStores/UA Applications folder.We strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a 'pull request'.
You must agree to the contributor license agreement before we can accept your changes. The CLA and "I AGREE" button is automatically displayed when you perform the pull request. You can preview CLA here.