Service cannot be started. An instance is already running.

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
skjangra
Full Member
Full Member
Posts: 9
Joined: 02 Jan 2017, 12:47

Service cannot be started. An instance is already running.

Post by skjangra »

hi,

Whenever i try to run OPC server, I find the below error in event viewer, but my service doesn't throw any error.
Only while running my application as window service, logs the below error in event viewer.
"Service cannot be started. An instance of the service is already running"

kindly check the below code.

Code: Select all

  LiveContext.Get().OPCServerManager = new CormatixServerManager();
                SecuredApplication application = new SecuredApplication();

                application.ApplicationName = "abc";
                application.ApplicationUri = "urn:localhost:abc";
                application.ApplicationType = UnifiedAutomation.UaSchema.ApplicationType.Server_0;
                application.ProductName = "my abc";
                application.BaseAddresses = new ListOfBaseAddresses();
                application.BaseAddresses.Add("opc.tcp://localhost:48030");

                ApplicationInstance.Default.SetApplicationSettings(application);

                ApplicationInstance.Default.Start(LiveContext.Get().OPCServerManager, null, LiveContext.Get().OPCServerManager);
My server starts without any error, but "LiveContext.Get().OPCServerManager.application" is always found null.

skjangra
Full Member
Full Member
Posts: 9
Joined: 02 Jan 2017, 12:47

Re: Service cannot be started. An instance is already runnin

Post by skjangra »

New observation : When we run it as a windows service, this application instance is null. Otherwise things work properly.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Service cannot be started. An instance is already runnin

Post by Support Team »

Hello,

you posted the same question at the support web form. We will post an answer here after we could solve your problem.
We are still waiting for answers from you.
Best regards
Unified Automation Support Team

MiguelF
Jr. Member
Jr. Member
Posts: 1
Joined: 31 Jan 2018, 10:58

Re: Service cannot be started. An instance is already runnin

Post by MiguelF »

Has this issue been solved yet? I am having the same problem. On Windows Forms everything runs perfectly but I keep getting this error when I try to run my OPC-UA client as a Service...

AlbertoM
Jr. Member
Jr. Member
Posts: 1
Joined: 25 Jul 2019, 09:10

Re: Service cannot be started. An instance is already runnin

Post by AlbertoM »

I'm picking up this old thread because I'm experiencing the same issue.
I use the OPC UA Client library in a Windows Service, and everything seems to work fine, but the event viewer is flooded with these errors:
"Service cannot be started. An instance of the service is already running"
Source: "OPC UA [Application name in xml configuration file]"
No error is caught in try...catch code.
Any help would be appreciated, thank you.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Service cannot be started. An instance is already runnin

Post by Support Team »

Hello,
if you want to integrate the OPC UA application into a windows service, you have to set ApplicationInstance.NoAutoStartService to 'false' before calling ApplicationInstance.Start.
See documentation.
Best regards
Unified Automation Support Team

aldebaran_wildt
Full Member
Full Member
Posts: 5
Joined: 11 Oct 2019, 16:04

Re: Service cannot be started. An instance is already running.

Post by aldebaran_wildt »

Hello,
I have the same problem, also with an OPC UA client in a windows service, same error message.
I set NoAutoStartService to false, and tried as well setting it to true, both didn't change anything.
Any more ideas?
Trank you!
BR,
Usch Wildt

aldebaran_wildt
Full Member
Full Member
Posts: 5
Joined: 11 Oct 2019, 16:04

Re: Service cannot be started. An instance is already running.

Post by aldebaran_wildt »

Hi,
I have just figured it out, or rather I have only now understood the hint from above correctly: You have to set the parameter NoAutoStartService to false and then call ApplicationInstance.Start explicitly. With implicit start of the ApplicationInstance when opening a connection the parameter is apparently not evaluated.
BR
Usch

Post Reply