Opc.Ua.Configuration.MainForm.RegisterWithDiscoveryServerBTN_Click C# (CSharp) Method

RegisterWithDiscoveryServerBTN_Click() private method

private RegisterWithDiscoveryServerBTN_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void RegisterWithDiscoveryServerBTN_Click(object sender, EventArgs e)
        {
            try
            {
                const string caption = "Register with Discovery Server";

                ManagedApplication application = ManageApplicationSecurityCTRL.GetSelectedApplication();

                if (application == null)
                {
                    return;
                }

                application.Reload();

                if (application.Certificate == null)
                {
                    MessageBox.Show(this, "Certificate is not specified.", caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // find discovery server.
                string path = Utils.FindInstalledFile("Opc.Ua.DiscoveryServer.exe");

                if (path == null)
                {
                    MessageBox.Show("Could not find the discovery server. Please confirm that it is installed.", caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                ManagedApplication lds = new ManagedApplication();
                lds.SetExecutableFile(path);

                if (!SetupTrustRelationship(application, lds))
                {
                    return;
                }

                MessageBox.Show("The Local Discovery Server now trusts the application.", caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }