How do I supress this dialog? "[server name] is already running on this host"

Hi,

Recently its come to my attention that this occasionally this dialog will pop up if multiple appservers are launched. My preference would be to log this and close the the app that tried to open. Please advise the best way to handle this.
2018-05-31_17-07-18
As always Thanks,

Todd

Hello

You need to override property IsCheckForOtherInstancesRequired of the application server class:

class AppServer : ApplicationServer
{
	public AppServer()
		: base("ServerName")
	{
	}

	protected override bool IsCheckForOtherInstancesRequired
	{
		get
		{
			return false;
		}
	}
}

This change will disable the built-in multiple instance check.

If you still need to check for multiple instances then you’ll need to implement the check code by yourself.
You can use code of the DetectOtherInstances the method from the ApplicationServer class as a sample.

Regards

1 Like

The override works perfectly. But I am unable to locate the “DetectOtherInstances the method from the ApplicationServer class”. Here is what I see in my ApplicationServer class.

#region Assembly RemObjects.SDK.Server, Version=9.3.105.1351, Culture=neutral, PublicKeyToken=3df3cad1b7aa5098
// C:\Program Files (x86)\RemObjects Software\RemObjects SDK for .NET\Bin\RemObjects.SDK.Server.dll
#endregion

using System;
using System.Security.Cryptography.X509Certificates;
using System.ServiceProcess;
using System.Windows.Forms;

namespace RemObjects.SDK.Server
{
public class ApplicationServer
{
public ApplicationServer(string applicationName, params Type serviceTypes);
public ApplicationServer(string applicationName, string rodlNamespace, params Type serviceTypes);
public ApplicationServer(string applicationName, string rodlNamespace, string serviceName, string serviceDescription, params Type serviceTypes);
protected ApplicationServer();

    public static ApplicationServer Instance { get; }
    protected static bool IsWindowsPlatform { get; }
    public ApplicationRunAction RunAction { get; }
    public INetworkServer NetworkServer { get; }
    public bool AutoCreateSelfSignedCertificate { get; set; }
    protected bool IsDebugEnabled { get; set; }
    protected bool IsAnotherInstanceDetected { get; }
    protected virtual string ApplicationName { get; }
    protected string[] ExtendedParameters { get; }
    protected virtual bool IsCheckForOtherInstancesRequired { get; }
    protected virtual string ExtendedParametersDescription { get; }
    protected virtual string ConsoleServerFooter { get; }
    protected virtual string HelpTextFooter { get; }
    protected virtual string ApplicationInfo { get; }
    protected virtual string ServiceName { get; }
    protected string RodlNamespace { get; set; }
    protected bool IsQuietModeEnabled { get; set; }
    protected virtual string Identifier { get; }

    public event EventHandler Starting;
    public event EventHandler Stopped;
    public event EventHandler<ApplicationServerExceptionEventArgs> ApplicationServerException;
    public event EventHandler<CertificateGeneratingEventArgs> CertificateGenerating;

    public void Run(string[] arguments);
    protected virtual INetworkServer CreateNetworkServer(INetworkServerConfiguration configuration);
    protected virtual Form CreateServerMainForm();
    protected virtual ServiceBase CreateServerWinService();
    protected virtual IArgumentParser GetArgumentParser();
    protected virtual string GetStartupOptionsHelpText();
    protected virtual void LoadApplicationServerConfiguration();
    protected virtual X509Certificate2 LoadSecurityCertificate();
    protected virtual void OnApplicationServerException(ApplicationServerExceptionEventArgs e);
    protected virtual void OnCertificateGenerating(CertificateGeneratingEventArgs e);
    protected virtual void OnStarting();
    protected virtual void OnStopped();
    protected virtual void ProcessExtendedParameters();
    protected virtual void RunAsConsoleApplication();
    protected virtual void RunAsWindowsApplication();
    protected virtual void RunAsWindowsService();
    protected virtual void RunAsWindowsServiceInstallation();
    protected virtual void RunAsWindowsServiceUninstallation();
    protected virtual void ShutdownAsConsoleApplication();
}

}

Am I missing something?

Never mind, I for got I had the source code to the project. I look at it and let you know if I have any issues.

1 Like