![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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()); } } |
| | #2 (permalink) |
| Guest | 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()); > } > } |
| |
| |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WCF service hosted in IIS | soworl | .NET General | 0 | 03-07-2008 10:56 AM |