473,626 Members | 3,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange Behaviour Over Windows Server in C#?

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.WriteE ntry(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.WriteE ntry(str_Value) ;
}

protected override void OnStop()
{
str_Value="Stop Command Triggerred";
}
Full Source Code here -
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Diagnost ics;
using System.ServiceP rocess;

namespace WindowsService
{
public class Service1 : System.ServiceP rocess.ServiceB ase
{
private System.Componen tModel.IContain er components;
private string str_Value="Defa ult Command Triggerred";

public Service1()
{
InitializeCompo nent();
}

static void Main()
{
System.ServiceP rocess.ServiceB ase[] ServicesToRun;
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
Service1() };
System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}

private void InitializeCompo nent()
{
components = new System.Componen tModel.Containe r();
this.ServiceNam e = "Service1";
}

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

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

protected override void OnStop()
{
str_Value="Stop Command Triggerred";
}
}
Jul 19 '05 #1
0 1286

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1538
by: Daniel O'Brien | last post by:
Hi - any help with this would be greatly appreicated - it has already had me confused for a good few hours! I am using Visual Studio 2003 and the .NET framework 1.1. I have a C# Windows Service, with my own class extending from ServiceBase in the normal fashion. The service starts a remoting object (WKO and singleton) which many clients can then make calls on. Clients may also register with events on the server such that the server...
3
2299
by: Andrew Mayo | last post by:
(note: reason for posting here; browser helper object is written in C++; C++ developers tend to know the intricacies of message handling; this looks like a Windows messaging issue) Microsoft very kindly make available a DLL (the browser helper DLL) which allows you to trap and disable the context menu (right mouse click) and various 'built-in' browser accelerators (such as ctrl+P which brings up the print dialogue, and F5, which will...
3
4866
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP Developer (SP3 for Office, SP1 for developer, JET40SP8) on Windows XP Home Edition (SP1). The same behaviour occurs on Windows 98 too.
1
2514
by: Jitesh Sinha | last post by:
Hi, I am running Windows 2003/ IIS 6.0. I was stuck with rather a abnormal behaviour of System.Web.mail class. It was truncating the message body after 3,071 character. The code i was testing was: Import Namespace="System.Web.Mail" Dim aa as new StringBuilder(600010) Dim i as Integer
0
1414
by: theintrepidfox | last post by:
Dear Group I came accross a very annoying behaviour of Visual Studio, giving me six hours of headache till I found the solution. This post is mainly for fellow developers for reference as it took me ages reading through tons of posts till I found an answer. However, I'm also interested why Visual Studio behaves that way. If anyone has a theorie on it please let me know.
4
2390
by: liam_weston | last post by:
I have 2 supposedly identical Windows 2000 web servers each with IIS5. Both have the ASPCODEPAGE set to 65001 (utf-8) in the metabase. The first server has been running pages like the one below for a long time and the output has been correct ie. the ™ character and international characters have displayed correctly (except that the ™ has never displayed correctly in the titlebar). My problem is that the second server is not displaying...
2
1175
by: Darren Newton | last post by:
Last month we upgraded our production server from .net 1.1 to 2.0. We have seen some odd behaviour that we do not know how to fix. It seems that Cache is reset or cleared. We have 2 or 3 global entries in the the cache with the NotRemovable flag set. I have set up a callback that writes an entry to the event log to see if the Cache is cleared. It appears that it is. This happens (randomly) several times a day. I changed our global...
4
1988
prometheuzz
by: prometheuzz | last post by:
Hello all, There's this problem I have, which I am unable to find a solution for. The problem is this: I cannot post messages with a specific size on (certain) forums. I hear you thinking: what has this to do with networking? Before I get burned to the stake, please hear me out. I have recently plugged a wireless router on my (wireless) modem because my modem could only be configured as a DHCP server and was not able to forward any traffic...
3
1681
by: Gotch | last post by:
Hi. I found a strange behaviour I cannot explain with the ' char. I do the following: 1) there is a string with ' inside. 2) I encode the string with urlencode, I put it in a $_GET variable 3) in the next page (pointed by the link that included the arg param), I do $str=urldecode($_GET) ... then ' comes out as \' ! (?)
8
5297
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples. (Sorry, long email) The first two examples are behaving normal, the thirth is strange....... I wrote the following flabbergasting code: #-------------------------------------------------------------
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.