Hi All,
I have a WCF Service library wrapped in a windows service being called from a standard Web App.
My web app has a reference to the windows service and calls the wcf process on the windows service in the following way:
In my windows service in my OnStart Event I have the following Code:Code:using (IRSService.RSClient WCF = new RSClient()) { WCF.ProcessBorderaux(); WCF.Close(); }
and my RunService method is defined:Code:Thread t = new Thread(new ThreadStart(RunService)); try { t.Start(); } catch { if (t.IsAlive) { t.Abort(); } throw; }
Once t.start has been initiated, I expect the process to bubble back up the chain and thus become detached from my client. However, The client still seems to be attached after my long running process has been started. and so then the client falls at the closing curly brace of my 'Using' Statement with the following error:Code:protected void RunService() { sHost = new ServiceHost(typeof(wcfBorderauxIRSService.IRSService)); sHost.Open(); ServiceEndpoint endpoint = sHost.Description.Endpoints[0]; EventLog.WriteEntry(endpoint.Contract.Name + " Started" + " listening on " + endpoint.Address + " (" + endpoint.Binding.Name + ")", System.Diagnostics.EventLogEntryType.Information); }
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
If I continue, my client crashes, but my service continues as I want.
How do I gracefully detach my Service from the client once the service has initiated successfully?
On my WCF Service, I have added to the interface the oneway attribute:
and on the Service I have adorned a ServiceBehaviour:Code:[ServiceContract] public interface IRS { [OperationContract(IsOneWay=true)] void ProcessBorderaux();
The idea being that with AutomaticSessionShutdown set, the service doesn't shut when the client does. However adding these have made little difference I know receive a timeout error relating to sockets, but it's still the same underlying issue of returning from the service as soon as the process has been called.Code:[ServiceBehavior(AutomaticSessionShutdown = false, UseSynchronizationContext = false, InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)] public class IRSService : IRS.....




Reply With Quote