Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

WCFService Hosted as Windows Service.

 
 
Thread Tools Display Modes
Old 06-26-2007   #1 (permalink)
Shailesh
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());
}
}
Old 07-05-2007   #2 (permalink)
Markus Strobl
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
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());
> }
> }



Old 07-19-2007   #3 (permalink)
evgshapiro@gmail.com
Guest


 

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).

 

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








Vistax64.com 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 2005-2008

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 47 48 49 50