.NET Based OPC UA Client/Server SDK  3.1.0.500
Application Instance

Overview

The ApplicationInstance inherits from the Application Instance Base and expands the application with configuration trouth the command line and run as service functionality.

Please read the Application Instance Base paragraph first.

An ApplicationInstance must be started before it can be used by calling the Start method. This executes the activity shown in the following figure:

l3baselibappinstanceoverview.png

Differences in Configuration

The LoadConfiguration action in Application Instance loads the Application configuration file from a file or a resource. This happens in a slightly different way then in the Application Instance Base. It looks in the following locations for a configuration file:

  1. The value of the /configFile command line parameter;
  2. The value of the ConfigurationFilePath property;
  3. The UaApplicationConfiguration configuration section in the app.config file;
  4. An embedded resource in the entry Assembly with a file name ‘ApplicationSettings.xml’.

If no ConfigurationFilePath is not set by command line or ConfigurationFilePath property, the application looks automatically in configuration section of the app.config file. If the SDK is used as an assembly by another application, the configuration should be set in code or by an external config file.

Enhancements to Base

The ProcessCommandLine action does any special processing based on the command line arguments. If no further processing is required, then the Start method exits.

The ParseCommandLine action validates the command line arguments. The command line syntax requires command keywords proceeded by a forward slash and followed by an optional parameter separated by a colon. For example:

/silent /configFile:"C:\My Config.xml"

Double quotes must be used to enclose parameters with whitespaces.

The ApplicationInstance class supports the following command line parameters:

ParameterDescription
/serviceStarts the application as a service (/service [/silent] [/configFile:<filepath>]).
It is necessary to set the parameter InstallAsService and ServiceName in the config file and install the application using /install (see below) first.
/installInstalls the application (/install [/silent] [/configFile:<filepath>]).
/uninstallUninstalls the application (/uninstall [/silent] [/configFile:<filepath>]).
/silentPerforms operations without prompting user to confirm or displaying errors.
/configFileThe configuration file to use with the application.

Application Developers can add support for additional arguments by creating a subclass of ApplicationInstance.

The RunAsService action starts the application as a Windows Service. This action will run if the application is launched by a non-interactive user. It passes control to the Service Control Manager (SCM) which will then complete the activity from a different thread. The Start method exits normally.

Application Developers can create subclasses of the ApplicationInstance object and customize the behavior of any of the activities.