473,811 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in windows service

3 New Member
Hi,

I am getting the following error when I try to start the windows service I have written:

ReadOutlookServ ice on local computer started and then stopped.Some services stop automatically if they have no work to do, for example the Performance logs and alerts service.

My Service.cs contains the following:
Expand|Select|Wrap|Line Numbers
  1.  protected override void OnStart(string[] args)
  2.         {
  3.             // TODO: Add code here to start your service.
  4.             eventLog1.WriteEntry("ReadOutLookService OnStart");
  5.  
  6.             tm.Enabled = true;
  7.             //tm.Start;
  8.             tm.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
  9.         }
  10.  
  11.        protected void Timer_Elapsed(object sender,
  12.          System.Timers.ElapsedEventArgs e)
  13.         {
  14.             try
  15.             {
  16.                 //eventLog1.WriteEntry("Timer started");
  17.                 _Application olApp = new ApplicationClass();
  18.                 _NameSpace olNs = olApp.GetNamespace("MAPI");
  19.                 MAPIFolder oInbox = olNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
  20.                 Items oItems = oInbox.Items;
  21.                 for (int i = 1; i <= oItems.Count; i++)
  22.                 {
  23.                     _MailItem oMail = (_MailItem)oItems.Find("DTE Time Reminder");
  24.                     oMail.Display(false);
  25.                 }
  26.  
  27.             }
  28.             catch (System.Exception ex)
  29.             {
  30.                 throw (ex);
  31.             }
  32.         }
  33.  
How do I debug the service ? The service gets installed, but I am not able to run it, since it starts and stops immediately.

Thanks in advance,
mrk
Oct 2 '09 #1
5 3455
PRR
750 Recognized Expert Contributor
Hi,
1. Try and log the error in a text file.
Expand|Select|Wrap|Line Numbers
  1. try{
  2.  
  3. }
  4. catch(Exception)
  5. {
  6. // code to log text file
  7. }
  8.  
2. Check the service account. It should have permission to write to event logs and file system.
Oct 2 '09 #2
mrk98
3 New Member
Hi,
Can you elaborate how I can give permission to the ServiceAccount to write to eventlog or file system ? I have used LocalSystem account.
Thanks,
mrk
Oct 2 '09 #3
mrk98
3 New Member
Can anybody give some pointers ? I just want to create and run a simple windows service..
Oct 3 '09 #4
PRR
750 Recognized Expert Contributor
Hi,
Run the service under "LocalSystem"(f or testing, later on maybe you can change it to some other account). This is the highest account( most privileged). Try and run the code in a console application, see if you find any bugs. If it runs fine, then maybe its a rights issue.
Creating Winsows service (look into ServiceAccount) .
Oct 5 '09 #5
Plater
7,872 Recognized Expert Expert
Generally when your service produces that "error" about starting and stopping, it means it had no work to do. Which would lead me to believe there is trouble in your OnStart call, in that the service control doesn't believe you are trying to do anything. Your timer_elapsed function might not be recognized as a true thread that does work?
Oct 5 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4506
by: B Golash | last post by:
Hi I`m trying to install a third-party control. During the install I receive this error...see the url below. I have no idea as to the meaning of the error. www.woodsolutions.com/download/ErrorLoadComp.jpg
0
3689
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob , /webapps/sue) and i have added the folders bob, sue in my server.xml(in the context path). When i am trying to run jsp files from my browser, it works fine. But, the following jsp files reports some exceptions which is quite hard to understand. Here is...
5
14131
by: Richard Steele | last post by:
I have created a WinForm application that needs to be run as a windows service (the PC is inaccesible by any user) i have successfully installed the application as a windows service. When i start the service, i get the following error Error 1053: The service did not respond to the start or control request in a timely fashion 1. Is there anyway to extend the timeout period.? I use timed threads to load a serial device driver and this...
4
7883
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service applications in a training class last week. The applications worked in the class, but when I tried to run them again over the weekend, they both bombed. Instead of getting my Web page, or the Web Service page, I get a page full of error text...
11
3145
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some useful utils that more pages on that server can use. As an example, I have created a Page Counter class that opens an Access .mdb file, counts the current entries for that page, and adds a new entry with some information regarding the current...
4
7306
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always get the same error message: "An error occurred while creating one or more registry entries. Please see C:\WINDOWS\sqlstp.log for details. The problem could be caused by a low registry quota condition" I have tried to clean the registry and i...
8
55685
by: Kevin D. | last post by:
Please note, I already posted this on the MySQL official forum, but received no response. I thought I'd try again in another location. My apologies to anyone reading this twice... Despite everything I've tried, I cannot get MySQL to start as a Windows service. However, I AM able to get it started via the mysqld-nt --console command. Here is my (funky) setup:
4
6813
by: Jason Richmeier | last post by:
I am sure this has been asked at least once before but I could not find anything when searching. If I set the value of the ExitCode property to 1066 for a windows service, the text "A service specific error occured: 0." How do I (if it is possible) change the value of the zero to something custom (like a "look in the event log for further information" message)? Thank you,
1
6571
by: =?Utf-8?B?cm9zczYxMw==?= | last post by:
I'm puzzled by an error message encountered while creating a Windows Service. In particular, I'm creating a second Windows Service within a Windows Service project, using Visual Studio 2005. The first service works fine. The second service appears to be registered correctly; yet I get the "System error 1083 has occurred." doing a "NET START ServiceName" in the DOS window along with: "The executable program that this service is...
2
12305
Frinavale
by: Frinavale | last post by:
I thought it would be nice to share the solution to my IIS headache with the rest of the world. I have developed a web application that has been distributed. Upon installing my application, some people encountered a "500 Internal Error" and of course blamed my software immediately (and got frustrated when uninstalling/reinstalling my software didn't fix the problem). Finally I was able to take a look at one of these computers and discovered...
0
9727
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
10647
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
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10133
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...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.