.NET Based OPC UA Client/Server SDK  3.3.1.531
Configuration Options

app.config File

The configuration can be placed in the app.config file of your application. Add your settings within a UaApplicationConfiguration section.

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="UaApplicationConfiguration" type="UnifiedAutomation.UaBase.ApplicationConfigurationSection,UnifiedAutomation.UaBase"/>
</configSections>
<UaApplicationConfiguration>
<SecuredApplication xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/2011/03/SecuredApplication.xsd" xmlns:ua="http://opcfoundation.org/UA/2008/02/Types.xsd">
<!-- Identify the Application -->
<ApplicationName>UaServerNet@localhost</ApplicationName>
<ApplicationUri>urn:localhost:UnifiedAutomation:UaServerNet</ApplicationUri>
...
<Extensions>
...
</Extensions>
</SecuredApplication>
</UaApplicationConfiguration>
</configuration>

For details look at the provided app.config files in our Client and Server examples.

External XML File

The configuration can be loaded by setting the value of the ConfigurationFilePath property or by passing the path to a XML file via command line.

Note
The command line option on only available in the ApplicationInstance class in the UaBase.Windows assembly. This file should contain only the SecuredApplication XML tag, as opposed to app.config.
<SecuredApplication xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/2011/03/SecuredApplication.xsd">
<!-- Identify the Application -->
<ApplicationName>UnifiedAutomation BasicClient</ApplicationName>
<ApplicationUri>urn:localhost:UnifiedAutomation:BasicClient</ApplicationUri>
<ProductName>UnifiedAutomation BasicClient</ProductName>
...
</SecuredApplication>

Embedded Resource XML File

The same XML config file as in External XML File can be set as embedded resource in the entry Assembly.

Note
The name of the xml file must always be ApplicationSettings.xml.

In Memory Configuration

InMemoryConfiguration allows to set the configuration in code. The following code from our ServerGettingStarted example shows how it can be used:

static void ConfigureOpcUaApplicationFromCode()
{
// fill in the application settings in code
// The configuration settings are typically provided by another module
// of the application or loaded from a data base. In this example the
// settings are hardcoded
var configuration = new ConfigurationInMemory();
string enviromentPath = "%CommonApplicationData%";
// override path for net core on non windows platform
if (!PlatformUtils.IsWindows()) enviromentPath = "%LocalApplicationData%";
// ***********************************************************************
// standard configuration options
// general application identification settings
configuration.ApplicationName = "UnifiedAutomation GettingStartedServer";
configuration.ApplicationUri = "urn:localhost:UnifiedAutomation:GettingStartedServer";
configuration.ApplicationType = UnifiedAutomation.UaSchema.ApplicationType.Server_0;
configuration.ProductName = "UnifiedAutomation GettingStartedServer";
// configure application certificate and paths to the certificate stores
configuration.SetSecurity(PlatformUtils.CombinePath(enviromentPath, "UnifiedAutomation", "pki"), "CN=GettingStartedServer/O=UnifiedAutomation/DC=localhost");
// configure endpoints
configuration.BaseAddresses = new UnifiedAutomation.UaSchema.ListOfBaseAddresses();
configuration.BaseAddresses.Add("opc.tcp://localhost:48030");
configuration.SecurityProfiles = new ListOfSecurityProfiles();
configuration.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.Basic256Sha256, Enabled = true });
configuration.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.Aes128Sha256RsaOaep, Enabled = true });
configuration.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.Aes256Sha256RsaPss, Enabled = true });
// This SecurityProfile is enabled for testing purposes. It shall NOT be enabled in end user products.
configuration.SecurityProfiles.Add(new SecurityProfile() { ProfileUri = SecurityProfiles.None, Enabled = true });
// ***********************************************************************
// extended configuration options
// trace settings
TraceSettings trace = new TraceSettings();
trace.MasterTraceEnabled = false;
trace.DefaultTraceLevel = UnifiedAutomation.UaSchema.TraceLevel.Info;
trace.TraceFile = PlatformUtils.CombinePath(enviromentPath, "UnifiedAutomation", "Logs", FilePathUtils.MakeValidFileName(configuration.ApplicationName) + ".log.txt");
trace.MaxLogFileBackups = 3;
trace.ModuleSettings = new ModuleTraceSettings[]
{
new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Stack", TraceEnabled = true },
new ModuleTraceSettings() { ModuleName = "UnifiedAutomation.Server", TraceEnabled = true },
};
configuration.Set<TraceSettings>(trace);
// Installation settings
InstallationSettings installation = new InstallationSettings();
installation.GenerateCertificateIfNone = true;
installation.DeleteCertificateOnUninstall = true;
configuration.Set<InstallationSettings>(installation);
configuration.ServerSettings = new ServerSettings()
{
ProductName = "UnifiedAutomation GettingStartedServer",
DiscoveryRegistration = new DiscoveryRegistrationSettings()
{
Enabled = false
},
Capabilities = new string[]
{
"DA"
},
ProductUri = "urn:unifiedautomation.gettingstarted"
};
// ***********************************************************************
// set the configuration for the application (must be called before start to have any effect).
// these settings are discarded if the /configFile flag is specified on the command line.
ApplicationInstanceBase.Default.SetApplicationSettings(configuration);
}

Default Configuration

If no configuration method is found, a default configuration is generated automatically. This is only for testing purposes. We highly recommended to use your own configuration.