![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | WCFService Hosted as Windows Service. Hi i am trying to host WCF service as a windows service The service has been installed successfully. I can see the my service in Service Configuration Manager (SCM) using services.msc but when i attempt to start the service it stops immediately with message: "The Service1 service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alert service" Here is some part of code that i have written. public partial class Service123 : ServiceBase { public ServiceHost serviceHost = null; public Service123() { InitializeComponent(); } protected override void OnStart(string[] args) { if (serviceHost != null) { serviceHost.Close(); } // Create a ServiceHost for the WcfCalculatorService type and provide the base address. serviceHost = new ServiceHost(typeof(MSMQServer123)); // Open the ServiceHostBase to create listeners and start listening for messages. serviceHost.Open(); } protected override void OnStop() { if (serviceHost != null) { serviceHost.Close(); serviceHost = null; } } } [ServiceContract] class MSMQServer123 { [OperationContract(IsOneWay = true)] // [FaultContract(typeof(DivideByZeroException))] void SayHi() { Console.WriteLine("Hi from Server"); throw new FaultException<DivideByZeroException>(new DivideByZeroException()); } } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: WCFService Hosted as Windows Service. Normally services refuse to start when an exception occurs. Try to catch the Exception on your OnStart - Method and log it to a file to see whats wrong. Maybe its due to a misconfiguration in your app.config - file. Greets Markus "Shailesh" <Shailesh@discussions.microsoft.com> schrieb im Newsbeitrag news C627F19-6707-40AA-B07D-5DF8D30C5E0B@microsoft.com...> Hi i am trying to host WCF service as a windows service The service has > been > installed successfully. I can see the my service in Service Configuration > Manager (SCM) using services.msc but when i attempt to start the service > it > stops immediately with message: > "The Service1 service on Local Computer started and then stopped. Some > services stop automatically if they have no work to do, for example, the > Performance Logs and Alert service" > Here is some part of code that i have written. > public partial class Service123 : ServiceBase > { > public ServiceHost serviceHost = null; > public Service123() > { > InitializeComponent(); > } > > protected override void OnStart(string[] args) > { > if (serviceHost != null) > { > serviceHost.Close(); > } > > // Create a ServiceHost for the WcfCalculatorService type and > provide the base address. > serviceHost = new ServiceHost(typeof(MSMQServer123)); > > // Open the ServiceHostBase to create listeners and start > listening for messages. > serviceHost.Open(); > } > > protected override void OnStop() > { > if (serviceHost != null) > { > serviceHost.Close(); > serviceHost = null; > } > } > } > [ServiceContract] > > class MSMQServer123 > { > > [OperationContract(IsOneWay = true)] > // [FaultContract(typeof(DivideByZeroException))] > void SayHi() > { > Console.WriteLine("Hi from Server"); > throw new FaultException<DivideByZeroException>(new > DivideByZeroException()); > } > } |
My System Specs![]() |
| | #3 (permalink) |
| | Re: WCFService Hosted as Windows Service. The errors in the applicatiopn are also logged in the Application Log of the Event Viewer (administrative tasks in the Control Panel). |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| WCF service hosted in IIS | .NET General | |||