473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error in windows service

3
Hi,

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

ReadOutlookService 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 3431
PRR
750 Expert 512MB
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
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
Can anybody give some pointers ? I just want to create and run a simple windows service..
Oct 3 '09 #4
PRR
750 Expert 512MB
Hi,
Run the service under "LocalSystem"(for 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 Expert 4TB
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
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. ...
0
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 ,...
5
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...
4
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...
11
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...
4
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...
8
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...
4
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...
1
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...

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.