OPC Studio User's Guide and Reference
ServerElement Class
Members  Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc Namespace : ServerElement Class
Contains information gathered about an OPC server.
Object Model
ServerElement ClassServerCategories ClassServerCategories Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.ComTypes._ServerElement)>
<ComVisibleAttribute(True)>
<FacetAttribute("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   OpcLabs.BaseLib.Media.IContent, 
   "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")>
<GuidAttribute("A1CE98D7-BA96-4572-9E44-BC2655161D14")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=False, 
   Export=True, 
   PageId=10001)>
<SerializableAttribute()>
Public NotInheritable Class ServerElement 
   Inherits OpcLabs.BaseLib.Info
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As ServerElement
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.ComTypes._ServerElement)]
[ComVisible(true)]
[Facet("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   OpcLabs.BaseLib.Media.IContent, 
   "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")]
[Guid("A1CE98D7-BA96-4572-9E44-BC2655161D14")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public sealed class ServerElement : OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.ComTypes._ServerElement)]
[ComVisible(true)]
[Facet("OpcLabs.EasyOpc.Forms.Implementation.ServerElementContent, OpcLabs.EasyOpcForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   OpcLabs.BaseLib.Media.IContent, 
   "{A1DB0591-3E22-43A2-A072-2B76C04BE0C0}")]
[Guid("A1CE98D7-BA96-4572-9E44-BC2655161D14")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public ref class ServerElement sealed : public OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.Text.IStringListSerializable, OpcLabs.EasyOpc.ComTypes._ServerElement, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

This object is filled in and returned e.g. when you browse a machine for a list of OPC servers installed on it.

There are implicit conversions from this type to:

If you want to retrieve a list of OPC Data Access servers registered on a local or remote computer, call the BrowseServers method, passing it the name or address of the remote machine (use empty string for local computer).

In OPC Data Client.NET, you will receive back a ServerElementCollection object. If you want to connect to this OPC server later in your code by calling other methods, use the built-in conversion of ServerElement to a String or ServerDescriptor, and pass the resulting string as a serverClass or a serverUrl argument either directly to the method call, or to a constructor of ServerDescriptor object.

In OPC Data Client-COM, if you want to connect to some OPC server later in your code by calling other methods, obtain the value of ServerElement.ServerClass property, and pass the resulting string as a serverClass argument to the method call that accepts it.

Each ServerElement contains information gathered about one OPC server found on the specified machine, including things like the server’s CLSID, ProgID, vendor name, and readable description. For an OPC XML server, it contains its URL.

Example 1

.NET

// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
//
// 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;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    class BrowseServers
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            ServerElementCollection serverElements;
            try
            {
                serverElements = client.BrowseServers("");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (ServerElement serverElement in serverElements)
                Console.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}");
        }


        // Example output:
        //
        //ServerElements("c8a12f17-1e03-401e-b53d-6c654dd576da").ProgId: OPCLabs.KitServer.2
    }
}
' This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' 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.

Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class BrowseServers
        Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim serverElements As ServerElementCollection
            Try
                serverElements = client.BrowseServers("")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each serverElement In serverElements
                Console.WriteLine($"ServerElements(""{serverElement.ClsidString}"").ProgId: {serverElement.ProgId}")
            Next serverElement

        End Sub

        ' Example output:
        '
        'ServerElements("c8a12f17-1e03-401e-b53d-6c654dd576da").ProgId: OPCLabs.KitServer.2
    End Class
End Namespace

COM

// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// 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.

var Client = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
var ServerElements = Client.BrowseServers("")

for (var objEnum = new Enumerator(ServerElements) ; !objEnum.atEnd() ; objEnum.moveNext()) {
    var ServerElement = objEnum.item();
    WScript.Echo("ServerElements(\"" + ServerElement.UrlString + "\").ProgId: " + ServerElement.ProgId);
}
// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// 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.

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

try
{
    $ServerElements = $Client->BrowseServers("");
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    Exit();
}

foreach ($ServerElements as $ServerElement)
{
    printf("ServerElements(\"s\").ProgIds\n", $ServerElement->ClsidString, $ServerElement->ProgId);
}
# This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client
from pywintypes import com_error

# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') 

# Perform the operation
try:
    serverElements = client.BrowseServers('')
except com_error as e:
    print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
    exit()

# Display results
for serverElement in serverElements:
    print('ServerElements("' + serverElement.ClsidString + '"): ' + serverElement.ProgId)
Rem This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim ServerElements: Set ServerElements = Client.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "ServerElements(""" & ServerElement.ClsidString & """).ProgId: " & ServerElement.ProgId
Next

Python

# This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# 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.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object
client = EasyDAClient()

# Perform the operation
try:
    serverElements = IEasyDAClientExtension.BrowseServers(client, '')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results
for serverElement in serverElements:
    print('ServerElements("' + serverElement.ClsidString + '"): ' + serverElement.ProgId)

Example 2

.NET

// This example shows all information available about categories that particular OPC servers do support.
//
// 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;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples._ServerCategories
{
    class General
    {
        public static void Main1()
        {
            // Instantiate the OPC-DA client object.
            var daClient = new EasyDAClient();

            Console.WriteLine();
            Console.WriteLine("OPC DATA ACCESS");
            ServerElementCollection daServerElements;
            try
            {
                daServerElements = daClient.BrowseServers();
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }
            DumpServerElements(daServerElements);

            // Instantiate the OPC-A&E client object.
            var aeClient = new EasyAEClient();

            Console.WriteLine();
            Console.WriteLine("OPC ALARMS AND EVENTS");
            ServerElementCollection aeServerElements;
            try
            {
                aeServerElements = aeClient.BrowseServers();
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }
            DumpServerElements(aeServerElements);
        }

        private static void DumpServerElements(ServerElementCollection serverElements)
        {
            foreach (ServerElement serverElement in serverElements)
            {
                Console.WriteLine($"Categories of \"{serverElement.ProgId}\":");
                ServerCategories serverCategories = serverElement.ServerCategories;
                Console.WriteLine($"    .OpcAlarmsAndEvents10: {serverCategories.OpcAlarmsAndEvents10}");
                Console.WriteLine($"    .OpcDataAccess10: {serverCategories.OpcDataAccess10}");
                Console.WriteLine($"    .OpcDataAccess20: {serverCategories.OpcDataAccess20}");
                Console.WriteLine($"    .OpcDataAccess30: {serverCategories.OpcDataAccess30}");
                Console.WriteLine($"    .ToString(): {serverCategories}");
            }
        }

        
        // Example output:
        //
        //OPC DATA ACCESS
        //Categories of "OPCLabs.KitServer.2":
        //    .OpcAlarmsAndEvents10: False
        //    .OpcDataAccess10: True
        //    .OpcDataAccess20: True
        //    .OpcDataAccess30: True
        //    .ToString(): (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
        //
        //OPC ALARMS AND EVENTS
        //Categories of "OPCLabs.KitEventServer.2":
        //    .OpcAlarmsAndEvents10: True
        //    .OpcDataAccess10: False
        //    .OpcDataAccess20: False
        //    .OpcDataAccess30: False
        //    .ToString(): (OpcAlarmsAndEvents10)
    }
}

COM

Rem This example shows all information available about categories that particular OPC servers do support.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Sub DumpServerElements(ByVal ServerElements)
Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "Categories of """ & ServerElement.ProgID & """:"
    With ServerElement.ServerCategories
        WScript.Echo Space(4) & ".OpcAlarmsAndEvents10: " & .OpcAlarmsAndEvents10
        WScript.Echo Space(4) & ".OpcDataAccess10: " & .OpcDataAccess10
        WScript.Echo Space(4) & ".OpcDataAccess20: " & .OpcDataAccess20
        WScript.Echo Space(4) & ".OpcDataAccess30: " & .OpcDataAccess30
        WScript.Echo Space(4) & ".ToString(): " & .ToString()
    End With
Next
End Sub



Dim DAClient: Set DAClient = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
WScript.Echo
WScript.Echo "OPC DATA ACCESS"
On Error Resume Next
Dim DAServerElements: Set DAServerElements = DAClient.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0
DumpServerElements DAServerElements

Dim AEClient: Set AEClient = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
WScript.Echo
WScript.Echo "OPC ALARMS AND EVENTS"
On Error Resume Next
Dim AEServerElements: Set AEServerElements = AEClient.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0
DumpServerElements AEServerElements

Example 3

.NET

// This example shows all information available about OPC servers.
//
// 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;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples._ServerElement
{
    class General
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerElementCollection serverElements;
            try
            {
                serverElements = client.BrowseServers();
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (ServerElement serverElement in serverElements)
            {
                Console.WriteLine($"Information about server \"{serverElement}\":");
                Console.WriteLine($"    .ServerClass: {serverElement.ServerClass}");
                Console.WriteLine($"    .ClsidString: {serverElement.ClsidString}");
                Console.WriteLine($"    .ProgId: {serverElement.ProgId}");
                Console.WriteLine($"    .Description: {serverElement.Description}");
                Console.WriteLine($"    .Vendor: {serverElement.Vendor}");
                Console.WriteLine($"    .ServerCategories: {serverElement.ServerCategories}");
                Console.WriteLine($"    .VersionIndependentProgId: {serverElement.VersionIndependentProgId}");
            }


            // Example output:
            //
            //Information about server "opcda:OPCLabs.KitServer.2%7Bc8a12f17-1e03-401e-b53d-6c654dd576da%7D":
            //    .ServerClass: OPCLabs.KitServer.2
            //    .ClsidString: c8a12f17-1e03-401e-b53d-6c654dd576da
            //    .ProgId: OPCLabs.KitServer.2
            //    .Description: OPC Labs Kit Server
            //    .Vendor: OPC Labs, http://www.opclabs.com
            //    .ServerCategories: (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
            //    .VersionIndependentProgId: OPCLabs.KitServer
        }
    }
}

COM

Rem This example shows all information available about OPC servers.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim ServerElements: Set ServerElements = Client.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "Information about server """ & ServerElement & """:"
    With ServerElement
        WScript.Echo Space(4) & ".ServerClass: " & .ServerClass
        WScript.Echo Space(4) & ".ClsidString: " & .ClsidString
        WScript.Echo Space(4) & ".ProgId: " & .ProgId
        WScript.Echo Space(4) & ".Description: " & .Description
        WScript.Echo Space(4) & ".Vendor: " & .Vendor
        WScript.Echo Space(4) & ".ServerCategories.ToString(): " & .ServerCategories.ToString()
        WScript.Echo Space(4) & ".VersionIndependentProgId: " & .VersionIndependentProgId
    End With
Next

 

 

Example
// This example shows all information available about OPC servers.
//
// 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;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples._ServerElement
{
    class General
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerElementCollection serverElements;
            try
            {
                serverElements = client.BrowseServers();
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (ServerElement serverElement in serverElements)
            {
                Console.WriteLine($"Information about server \"{serverElement}\":");
                Console.WriteLine($"    .ServerClass: {serverElement.ServerClass}");
                Console.WriteLine($"    .ClsidString: {serverElement.ClsidString}");
                Console.WriteLine($"    .ProgId: {serverElement.ProgId}");
                Console.WriteLine($"    .Description: {serverElement.Description}");
                Console.WriteLine($"    .Vendor: {serverElement.Vendor}");
                Console.WriteLine($"    .ServerCategories: {serverElement.ServerCategories}");
                Console.WriteLine($"    .VersionIndependentProgId: {serverElement.VersionIndependentProgId}");
            }


            // Example output:
            //
            //Information about server "opcda:OPCLabs.KitServer.2%7Bc8a12f17-1e03-401e-b53d-6c654dd576da%7D":
            //    .ServerClass: OPCLabs.KitServer.2
            //    .ClsidString: c8a12f17-1e03-401e-b53d-6c654dd576da
            //    .ProgId: OPCLabs.KitServer.2
            //    .Description: OPC Labs Kit Server
            //    .Vendor: OPC Labs, http://www.opclabs.com
            //    .ServerCategories: (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
            //    .VersionIndependentProgId: OPCLabs.KitServer
        }
    }
}
' This example shows all information available about OPC servers.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' 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.

Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace _ServerElement
    Partial Friend Class General
        Shared Sub Main1()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            Dim serverElements As ServerElementCollection
            Try
                serverElements = client.BrowseServers("")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each serverElement In serverElements
                Console.WriteLine($"Information about server ""{serverElement}"":")
                Console.WriteLine($"    .ServerClass: {serverElement.ServerClass}")
                Console.WriteLine($"    .ClsidString: {serverElement.ClsidString}")
                Console.WriteLine($"    .ProgId: {serverElement.ProgId}")
                Console.WriteLine($"    .Description: {serverElement.Description}")
                Console.WriteLine($"    .Vendor: {serverElement.Vendor}")
                Console.WriteLine($"    .ServerCategories: {serverElement.ServerCategories}")
                Console.WriteLine($"    .VersionIndependentProgId: {serverElement.VersionIndependentProgId}")
            Next serverElement

        End Sub

        ' Example output
        '
        'Information about server "opcda:OPCLabs.KitServer.2%7Bc8a12f17-1e03-401e-b53d-6c654dd576da%7D":
        '    .ServerClass OPCLabs.KitServer.2
        '    .ClsidString: c8a12f17-1e03-401e-b53d-6c654dd576da
        '    .ProgId: OPCLabs.KitServer.2
        '    .Description: OPC Labs Kit Server
        '    .Vendor: OPC Labs, http : 'www.opclabs.com
        '    .ServerCategories: (OpcDataAccess10, OpcDataAccess20, OpcDataAccess30)
        '    .VersionIndependentProgId: OPCLabs.KitServer
    End Class
End Namespace
Rem This example shows all information available about OPC servers.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim ServerElements: Set ServerElements = Client.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "Information about server """ & ServerElement & """:"
    With ServerElement
        WScript.Echo Space(4) & ".ServerClass: " & .ServerClass
        WScript.Echo Space(4) & ".ClsidString: " & .ClsidString
        WScript.Echo Space(4) & ".ProgId: " & .ProgId
        WScript.Echo Space(4) & ".Description: " & .Description
        WScript.Echo Space(4) & ".Vendor: " & .Vendor
        WScript.Echo Space(4) & ".ServerCategories.ToString(): " & .ServerCategories.ToString()
        WScript.Echo Space(4) & ".VersionIndependentProgId: " & .VersionIndependentProgId
    End With
Next
# This example shows all information available about OPC servers.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# 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.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

try:
    serverElements = IEasyDAClientExtension.BrowseServers(client)
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results
for serverElement in serverElements:
    print('Information about server ', serverElement, ':', sep='')
    print('    .ServerClass: ', serverElement.ServerClass, sep='')
    print('    .ClsidString: ', serverElement.ClsidString, sep='')
    print('    .ProgId: ', serverElement.ProgId, sep='')
    print('    .Description: ', serverElement.Description, sep='')
    print('    .Vendor: ', serverElement.Vendor, sep='')
    print('    .ServerCategories: ', serverElement.ServerCategories, sep='')
    print('    .VersionIndependentProgId: ', serverElement.VersionIndependentProgId, sep='')
Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.EasyOpc.ServerElement

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