Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - WCFService Hosted as Windows Service.

 
 
Old 06-26-2007   #1 (permalink)
Shailesh


 
 

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 SpecsSystem Spec
Old 07-05-2007   #2 (permalink)
Markus Strobl


 
 

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
newsC627F19-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 SpecsSystem Spec
Old 07-19-2007   #3 (permalink)
evgshapiro@gmail.com


 
 

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 SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
WCF service hosted in IIS .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46