Connectivity Software User's Guide and Reference
Installed Examples - Server Windows Service - UAServerWindowsServiceDemo
// A fully functional OPC UA demo server running in Windows service host.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.ServiceProcess;

namespace UAServerWindowsServiceDemo
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            var servicesToRun = new ServiceBase[]
            {
                new UAService1()
            };
            ServiceBase.Run(servicesToRun);
        }
    }
}
' A fully functional OPC UA demo server running in Windows service host.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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 System.ServiceProcess
Namespace Global.UAServerWindowsServiceDemo
    Module Program
        ''' <summary>
        ''' The main entry point for the application.
        ''' </summary>
        Sub Main()
            Dim servicesToRun = New ServiceBase() _
            {
                New UAService1()
            }
            ServiceBase.Run(servicesToRun)
        End Sub

    End Module
End Namespace
// A fully functional OPC UA demo server running in Windows service host.
//
// See also:
// https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-add-installers-to-your-service-application
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.ComponentModel;

namespace UAServerWindowsServiceDemo
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }
    }
}
' A fully functional OPC UA demo server running in Windows service host.
'
' See also:
' https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-add-installers-to-your-service-application
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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 System.ComponentModel

Namespace Global.UAServerWindowsServiceDemo
    <RunInstaller(True)>
    Public Class ProjectInstaller
        Inherits System.Configuration.Install.Installer
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub

    End Class
End Namespace
// A fully functional OPC UA demo server running in Windows service host.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.

namespace UAServerWindowsServiceDemo
{
    partial class ProjectInstaller
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
            this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
            // 
            // serviceProcessInstaller1
            // 
            this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
            this.serviceProcessInstaller1.Password = null;
            this.serviceProcessInstaller1.Username = null;
            // 
            // serviceInstaller1
            // 
            this.serviceInstaller1.Description = "This server demo is written in .NET, and it shows how to use the component to cre" +
    "ate an OPC UA server hosted in a Windows service. It provides readable and writa" +
    "ble nodes of various types.";
            this.serviceInstaller1.DisplayName = "OPC Wizard .NET Windows Service Demo";
            this.serviceInstaller1.ServiceName = "OpcWizardDemo";
            // 
            // ProjectInstaller
            // 
            this.Installers.AddRange(new System.Configuration.Install.Installer[] {
            this.serviceProcessInstaller1,
            this.serviceInstaller1});

        }
' A fully functional OPC UA demo server running in Windows service host.
'
' See also:
' https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-add-installers-to-your-service-application
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.

Namespace Global.UAServerWindowsServiceDemo
    Partial Class ProjectInstaller
        Inherits System.Configuration.Install.Installer

        'Installer overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()>
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        'Required by the Component Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Component Designer
        'It can be modified using the Component Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()>
        Private Sub InitializeComponent()
            Me.serviceProcessInstaller1 = New ServiceProcess.ServiceProcessInstaller()
            Me.serviceInstaller1 = New ServiceProcess.ServiceInstaller()
            '
            ' serviceProcessInstaller1
            '
            Me.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem
            Me.serviceProcessInstaller1.Password = Nothing
            Me.serviceProcessInstaller1.Username = Nothing
            '
            ' serviceInstaller1
            '
            Me.serviceInstaller1.Description = "This server demo is written in .NET, and it shows how to use the component to cre" +
        "ate an OPC UA server hosted in a Windows service. It provides readable and writa" +
        "ble nodes of various types."
            Me.serviceInstaller1.DisplayName = "OPC Wizard .NET Windows Service Demo"
            Me.serviceInstaller1.ServiceName = "OpcWizardDemo"
            '
            ' ProjectInstaller
            '
            Me.Installers.AddRange(New System.Configuration.Install.Installer() {
                Me.serviceProcessInstaller1,
                Me.serviceInstaller1})
        End Sub

        Private serviceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller
        Private serviceInstaller1 As System.ServiceProcess.ServiceInstaller
    End Class
End Namespace
// UAServerWindowsServiceDemo: Shows how to use the component to create an OPC UA server hosted in a Windows service. It
// provides readable and writable nodes of various types.
//
// Install the service by running:
//      C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /i UAServerWindowsServiceDemo.exe
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.ServiceProcess;
using OpcLabs.EasyOpc.UA;
using UAServerDemoLibrary;

namespace UAServerWindowsServiceDemo
{
    public partial class UAService1 : ServiceBase
    {
        public UAService1()
        {
            InitializeComponent();

            // Define various nodes.
            ConsoleNodes.AddToParent(_server.Objects);
            DataNodes.AddToParent(_server.Objects);
            DemoNodes.AddToParent(_server.Objects);
        }

        protected override void OnStart(string[] args)
        {
            // Start the server.
            _server.Start();
        }

        protected override void OnStop()
        {
            // Stop the server.
            _server.Stop();
        }

        // The server object.
        // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
        private readonly EasyUAServer _server = new EasyUAServer();
    }
}
' UAServerWindowsServiceDemo: Shows how to use the component to create an OPC UA server hosted in a Windows service. It
' provides readable and writable nodes of various types.
'
' Install the service by running:
'      C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /i UAServerWindowsServiceDemo.exe
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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 System.ServiceProcess
Imports OpcLabs.EasyOpc.UA
Imports UAServerDemoLibrary

Namespace Global.UAServerWindowsServiceDemo
    Partial Public Class UAService1
        Inherits ServiceBase

        Public Sub New()
            InitializeComponent()

            ' Define various nodes.
            ConsoleNodes.AddToParent(_server.Objects)
            DataNodes.AddToParent(_server.Objects)
            DemoNodes.AddToParent(_server.Objects)
        End Sub

        Protected Overrides Sub OnStart(ByVal args() As String)
            ' Start the server.
            _server.Start()
        End Sub

        Protected Overrides Sub OnStop()
            ' Stop the server.
            _server.Stop()
        End Sub

        Private ReadOnly _server As EasyUAServer = New EasyUAServer()
    End Class
End Namespace
// UAServerWindowsServiceDemo: Shows how to use the component to create an OPC UA server hosted in a Windows service. It
// provides readable and writable nodes of various types.
//
// Install the service by running:
//      C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /i UAServerWindowsServiceDemo.exe
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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.

namespace UAServerWindowsServiceDemo
{
    partial class UAService1
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.easyUAServer1 = new OpcLabs.EasyOpc.UA.EasyUAServer(this.components);
            // 
            // easyUAServer1
            // 
            // UAService1
            // 
            this.ServiceName = "OpcWizardDemo";

        }
' UAServerWindowsServiceDemo: Shows how to use the component to create an OPC UA server hosted in a Windows service. It
' provides readable and writable nodes of various types.
'
' Install the service by running:
'      C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /i UAServerWindowsServiceDemo.exe
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-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 System.ServiceProcess

Namespace Global.UAServerWindowsServiceDemo
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
    Partial Class UAService1
        Inherits ServiceBase

        'UserService overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()>
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        'Required by the Component Designer
        Private components As System.ComponentModel.IContainer

        ' NOTE: The following procedure is required by the Component Designer
        ' It can be modified using the Component Designer.  Do not modify it
        ' using the code editor.
        <System.Diagnostics.DebuggerStepThrough()>
        Private Sub InitializeComponent()
            components = New System.ComponentModel.Container()
            easyUAServer1 = New OpcLabs.EasyOpc.UA.EasyUAServer(Me.components)
            '
            ' easyUAServer1
            '
            ' UAService1
            '
            Me.ServiceName = "OpcWizardDemo"
        End Sub

        Private easyUAServer1 As OpcLabs.EasyOpc.UA.EasyUAServer
    End Class
End Namespace
See Also

Installed Examples - Client Windows Service

Installed Examples - Server Worker Service

Installed Examples - Server Console

Installed Examples - Server Library

Installed Examples - Server Windows Forms

Examples - Server OPC Unified Architecture