Click here to Skip to main content
15,074,987 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
I hava a WCF service which is hosted in a windows service. In the windows service installer i have set the services on which my service is dependent on(like Event Log, Cryptographic service ... - the stuff my host needs). On a standard windows machine everything is working fine. The problems begin when I install the same service on a Tablet PC running Windows XP. It seems that at the time when the sistem tries to start the service, the network is not yet set up and the service failes to start. So even though I have the service set as automatic, when the windows boots, the service is stopped. Does anyobody has any ideas how to solve that problem. Is there any other services for which my service should wait before it starts or is there maybe any other way to solve my problem.

Thanks in advance,
Uroš
Posted

You'll have to add code to your WCF service to handle that. You cannot always rely on the network being up. What you could do is to detect if the network is up, and if so continue. If the network is down, wait for a while and retry connection.
   
Comments
koleraba 13-Apr-11 21:04pm
   
Hi
Thanks for your answer. What approach do you propose? Like just to start the host and if that throws try again later, or do you know of any better way. Since the tablet has to be connected to a specific WiFi in order to work I was thinking about detecting a change in the name of the WiFi network to which the tablet is connected.
Espen Harlinn 19-Apr-11 16:38pm
   
Good advice, my 5
Nish Nishant 19-Apr-11 16:39pm
   
Thank you, Espen!
If your WCF service needs to handle partially connected scenarios, consider one-way semantics for the operations as this enables WCF to use MSMQ.

Take a look at:
SOA'izing MSMQ with WCF (and Why It's Worth It) [^]

This article should be *very* interesting:
WCF: Duplex MSMQ[^]

Regards
Espen Harlinn
   
Comments
Nish Nishant 19-Apr-11 17:02pm
   
Useful info, my 5!
Espen Harlinn 19-Apr-11 17:06pm
   
Thank you Nishant - WCF: Duplex MSMQ is certainly an underappreciated article :)
Sergey Alexandrovich Kryukov 19-Apr-11 17:19pm
   
Very useful, my 5.
--SA
Espen Harlinn 19-Apr-11 17:23pm
   
Thank you, SAKryukov!
Another option would be to make your windows service dependent on another windows service for example the network service. Check the dependencies tab on an installed windows service.

You can program this in the service installer. Below is an example.

C#
using (ServiceProcessInstaller processInstaller = new ServiceProcessInstaller())
{
    processInstaller.Account = ServiceAccount.LocalSystem;
    processInstaller.Username = null;
    processInstaller.Password = null;

    using (ServiceInstaller installer = new ServiceInstaller())
    {
        installer.DisplayName = "My wonderful windows service.";
        installer.StartType = ServiceStartMode.Automatic;
        installer.ServiceName = "MyService";

        installer.ServicesDependedOn = new string [] { "COMSysApp" };

        this.Installers.Add(processInstaller);
        this.Installers.Add(installer);
    }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900