PC Review


Reply
Thread Tools Rate Thread

Strange Behaviour Over Windows Server in C#?

 
 
nigil
Guest
Posts: n/a
 
      15th Jul 2003
hi guys..

anyone encounter this problem ?,... here it's goes.
look at the Start and Stop Method. I have set the variable str_Value="Stop
Command Triggerred"
on the Stop Function. then Start the Service again.. by right the
EventLog.WriteEntry(str_Value) should be
writing "Stop Command Triggerred" in the Event Viewer Console cos my string
variables is declared
within the constructer and not inside the method. but apparently it turns
out differently.
I have got "Default Command Triggerred" from the Event Viewer Console.

protected override void OnStart(string[] args)
{
EventLog.WriteEntry(str_Value);
}

protected override void OnStop()
{
str_Value="Stop Command Triggerred";
}


Full Source Code here -
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;

namespace WindowsService
{
public class Service1 : System.ServiceProcess.ServiceBase
{
private System.ComponentModel.IContainer components;
private string str_Value="Default Command Triggerred";

public Service1()
{
InitializeComponent();
}

static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
Service1() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}

private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "Service1";
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

protected override void OnStart(string[] args)
{
EventLog.WriteEntry(str_Value);
}

protected override void OnStop()
{
str_Value="Stop Command Triggerred";
}
}


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BCM shutting down over and over and over and over TheMurf Microsoft Outlook BCM 1 9th Mar 2007 03:32 PM
Getting same message over and over and over and over each day =?Utf-8?B?Z29pbmJhdHR5?= Microsoft Outlook 1 18th Nov 2005 10:52 PM
XP Login Over & Over & Over & Over Desert Rat Windows XP Help 1 30th Oct 2004 02:37 AM
Outlook 2002 crashes over and over and over and over and over and over typoo Microsoft Outlook Discussion 5 7th Mar 2004 08:12 PM
Strange Behaviour Over Windows Server in C#? nigil Microsoft Dot NET Framework 0 15th Jul 2003 05:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 AM.