OPC Studio User's Guide and Reference
GetApplicationElement Method (IEasyUAClientServerApplicationExtension)
Example 



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Application.Extensions Namespace > IEasyUAClientServerApplicationExtension Class : GetApplicationElement Method
The OPC UA client/server application object that will perform the operation.

In client applications, this is typically obtained by calling System.IServiceProvider.GetService(System.Type) on the OpcLabs.EasyOpc.UA.IEasyUAClient (EasyUAClient object) with the type of OpcLabs.EasyOpc.UA.Application.IEasyUAClientServerApplication as an argument.

The value of this parameter cannot be null (Nothing in Visual Basic).

Gets the OPC UA registration information for this application.
Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Shared Function GetApplicationElement( _
   ByVal application As IEasyUAClientServerApplication _
) As UAApplicationElement
 
'Usage
 
Dim application As IEasyUAClientServerApplication
Dim value As UAApplicationElement
 
value = IEasyUAClientServerApplicationExtension.GetApplicationElement(application)

Parameters

application
The OPC UA client/server application object that will perform the operation.

In client applications, this is typically obtained by calling System.IServiceProvider.GetService(System.Type) on the OpcLabs.EasyOpc.UA.IEasyUAClient (EasyUAClient object) with the type of OpcLabs.EasyOpc.UA.Application.IEasyUAClientServerApplication as an argument.

The value of this parameter cannot be null (Nothing in Visual Basic).

Return Value

Returns the application element describing how the application is configured to register itself in OPC UA ecosystem.

Because OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement has an implicit conversion to OpcLabs.EasyOpc.UA.UAEndpointDescriptor, you can simply use the returned OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement in any place where OpcLabs.EasyOpc.UA.UAEndpointDescriptor is expected as input, and the corresponding endpoint descriptor will be constructed automatically from the application element. When the implicit conversion operators are not supported (such as with Python.NET), you can use the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement.ToUAEndpointDescriptor static method instead.

This method never returns null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The OPC UA operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Remarks

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

Example
// Shows how to get the OPC UA registration information for this application.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA.Application;
using OpcLabs.EasyOpc.UA.Application.Extensions;
using OpcLabs.EasyOpc.UA.Discovery;

namespace UADocExamples.Application._IEasyUAClientServerApplication
{
    class GetApplicationElement
    {
        public static void Main1()
        {
            // Obtain the application interface.
            EasyUAApplication application = EasyUAApplication.Instance;

            // Get the OPC UA registration information for this application.
            UAApplicationElement applicationElement = application.GetApplicationElement();

            // Display results
            Console.WriteLine("Application element:");
            Console.WriteLine("  Application name: {0}", applicationElement.ApplicationName);
            Console.WriteLine("  Application type: {0}", applicationElement.ApplicationType);
            Console.WriteLine("  Application URI string: {0}", applicationElement.ApplicationUriString);
            Console.WriteLine("  Discovery URI strings: {0}", applicationElement.DiscoveryUriStrings);
            Console.WriteLine("  Product URI string: {0}", applicationElement.ProductUriString);
        }
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also