OPC UA .NET SDK Configuration: Difference between revisions

From OPC Labs Knowledge Base
No edit summary
No edit summary
Line 54: Line 54:
<p>If you switch your application so that its UA configuration is placed in an external file like described above, you can then also use the “[[Tool_Downloads#UA_Configuration_Tool|UA Configuration
<p>If you switch your application so that its UA configuration is placed in an external file like described above, you can then also use the “[[Tool_Downloads#UA_Configuration_Tool|UA Configuration
Tool]]” from OPC Foundation to configure certain parameters for the application (mainly, the security-related settings).</p>
Tool]]” from OPC Foundation to configure certain parameters for the application (mainly, the security-related settings).</p>
= Web applications in .NET Framework =
The above discussion applies to Web applications in .NET Framework with one difference: Instead of the '''app.config''' file, the so-called root '''Web.config''' file is used (see [https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/the-configuration-system-in-iis-7 The Configuration System in IIS 7]).

Revision as of 11:29, 7 May 2023

QuickOPC internally uses .NET Stack and SDK from OPC Foundation for its OPC UA (client-server) operations. The stack and SDK have many configurable parameters, and QuickOPC automatically sets them so that in most cases, you do not have to do any extra steps in this respect. Some of the parameters of the stack and SDK and exposed as configurable parameters in QuickOPC. For advanced purposes, it is possible to manually provide a configuration file for OPC UA .NET Stack and SDK. This feature belongs to Low-Level Configuration, and when it is enabled, the whole set of parameters for OPC UA .NET Stack and SDK becomes accessible to you. The UA configuration file can be placed alongside the application’s executable, and given the same, but a file extension of “.config.xml”. Such file will automatically be found and used, with no extra settings needed. If you want to place the UA configuration file elsewhere or give it a different name, you need to make several other steps yourself then:

  1. Add an entry for a new configuration section, named “UAClientEngine”, into the application configuration file. In Visual Studio, you typically design the contents of the application configuration file is in the app.config file in your project. Note that Visual Studio creates a renamed copy of this file in the build output directory; its actual name in runtime is constructed by taking the full name of the executable (including its extension, such as .exe or .dll), and appending .config to it (so that it becomes something like MyApplication.exe.config, for example). If you do not have this file in your project, add it first. After making this change, the beginning of this file may look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
         <section name="UAClientEngine" type="Opc.Ua.ApplicationConfigurationSection,Opc.Ua.Core" />
       </configSections>
           
    ...
    
  2. Add a “UAClientEngine” element into the application configuration file. The main purpose of this element is to refer to an external XML file that contains the UA configuration. The element may look like this:

    <UAClientEngine>
       <ConfigurationLocation xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd">
         <FilePath>MyApplication.Config.xml</FilePath>
       </ConfigurationLocation>
    </UAClientEngine>
    
  3. Create the UA configuration file with the name specified above, and fill it with settings you need. Unless specified otherwise, the file should be placed alongside the executable of your application.


Please refer to the OPC UA .NET Stack and SDK documentation for information on sections and parameters in the app.config file and in the UA configuration file. Following are examples of what can be changed using the UA configuration file:

  • Transport configurations
  • Transport quotas and timeouts
  • Trace configuration

If you switch your application so that its UA configuration is placed in an external file like described above, you can then also use the “UA Configuration Tool” from OPC Foundation to configure certain parameters for the application (mainly, the security-related settings).

Web applications in .NET Framework

The above discussion applies to Web applications in .NET Framework with one difference: Instead of the app.config file, the so-called root Web.config file is used (see The Configuration System in IIS 7).