473,714 Members | 4,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Service Starts and Immediately Stops

Hi.

I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it exits immediately with a start/stop/nothing to
do error.

What could be wrong?

My OnStart looks like this:

protected override void OnStart(string[] args)
{
InitIndexer();
}

and InitIndexer() is a lengthly bit of code making up the meat of the
service.

any ideas?

thanks.
Jan 7 '08 #1
41 11648
On Jan 7, 10:11*am, pbd22 <dush...@gmail. comwrote:
Hi.

I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it exits immediately with a start/stop/nothing to
do error.

What could be wrong?

My OnStart looks like this:

*protected override void OnStart(string[] args)
* * * * {
* * * * * * InitIndexer();
* * * * }

and InitIndexer() is a lengthly bit of code making up the meat of the
service.

any ideas?

thanks.
services can be a bit of a pain to debug as you can't just attach a
debugger. as you'll want event logging before you release your app
anyway, mind as well just put it in now, and use it for debugging
also. you can then trace out exactly what you want in your code and
see where things go ary.

your log method is simple, something like:

private void LogEvent(string LogMessage, EventLogEntryTy pe
LogEntryType)
{
if (!EventLog.Sour ceExists(_event Source))
{
EventLog.Create EventSource(_ev entSource, _logAppName);
}

EventLog MyLog = new EventLog();
MyLog.Source = _eventSource;
MyLog.WriteEntr y(LogMessage, LogEntryType);
}

with caller

LogEvent(string .Format("Error in Service:OnStart () {1}", ex.Message),
EventLogEntryTy pe.Error);

dave
Jan 7 '08 #2
Thanks Dave,

So, the code should look like this? :

protected override void OnStart(string[] args)
{
try
{
InitIndexer();
}
catch(Exception ex)
{
LogEvent(string .Format("Error in
VBIndexerServic e:OnStart() {1}", ex.Message),
EventLogEntryTy pe.Error);
}
}
Jan 7 '08 #3
OK.

Went to the event logs and see all sorts of COM object access denied
errors.
Seems the DLLs I registered in the DEV environment are not firing when
I
move everything to the production server (my guess).

Example:

Event Type: Error
Event Source: My Source
Event Category: None
Event ID: 0
Date: 1/7/2008
Time: 1:29:54 PM
User: N/A
Computer: My Computer
Description:
WindowsXYZServe r.GetSpace() Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED ))

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Question:

If I register a DLL as a certain path in my DEV system, say:

C:/x/y/z/library.DLL

and then I move the windows service to:

C:/a/b/c/

and put the DLLs in

C:/a/b/c/library.DLL

does that fudge up everything?

Must the path of the DLL files in the development
system match the path of the DLL files on the live server?

Thanks.
Jan 7 '08 #4
Hi,
The OnStart is suppose to be short, the solution to your problem execute
your method in another thread:

protected override void OnStart(string[] args)
{
new Thread( new ThreadStart( InitIndexer)).S tart();
}
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"pbd22" <du*****@gmail. comwrote in message
news:1a******** *************** ***********@41g 2000hsy.googleg roups.com...
Hi.

I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it exits immediately with a start/stop/nothing to
do error.

What could be wrong?

My OnStart looks like this:

protected override void OnStart(string[] args)
{
InitIndexer();
}

and InitIndexer() is a lengthly bit of code making up the meat of the
service.

any ideas?

thanks.

Jan 7 '08 #5
Hi,

See my other post for a solution, Your problem is taht the window's service
control manager expect that the service startup be complete in a short
amount of time. Otherwise it stop it. You have to use a thread.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"pbd22" <du*****@gmail. comwrote in message
news:f3******** *************** ***********@d70 g2000hsb.google groups.com...
Thanks Dave,

So, the code should look like this? :

protected override void OnStart(string[] args)
{
try
{
InitIndexer();
}
catch(Exception ex)
{
LogEvent(string .Format("Error in
VBIndexerServic e:OnStart() {1}", ex.Message),
EventLogEntryTy pe.Error);
}
}

Jan 7 '08 #6
"pbd22" <du*****@gmail. comwrote in message
news:81******** *************** ***********@k39 g2000hsf.google groups.com...
OK.

Went to the event logs and see all sorts of COM object access denied
errors.
Seems the DLLs I registered in the DEV environment are not firing when
I
move everything to the production server (my guess).

Example:

Event Type: Error
Event Source: My Source
Event Category: None
Event ID: 0
Date: 1/7/2008
Time: 1:29:54 PM
User: N/A
Computer: My Computer
Description:
WindowsXYZServe r.GetSpace() Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED ))

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Question:

If I register a DLL as a certain path in my DEV system, say:

C:/x/y/z/library.DLL

and then I move the windows service to:

C:/a/b/c/

and put the DLLs in

C:/a/b/c/library.DLL

does that fudge up everything?

Must the path of the DLL files in the development
system match the path of the DLL files on the live server?

Thanks.

We can't help you if you don't tell us what the code is doing, only posting
a snippet that shows nothing isn't of any help.
From the above it looks like (suppose the eventlog entries have something to
do with the service) you are calling a COM server, for which the caller has
no access permissions. So, you'll have to adjust the Access Permissions for
the COM server using DCOMCNFG.

Willy.

Jan 7 '08 #7
On Jan 7, 2:19 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
"pbd22" <dush...@gmail. comwrote in message

news:81******** *************** ***********@k39 g2000hsf.google groups.com...
OK.
Went to the event logs and see all sorts of COM object access denied
errors.
Seems the DLLs I registered in the DEV environment are not firing when
I
move everything to the production server (my guess).
Example:
Event Type: Error
Event Source: My Source
Event Category: None
Event ID: 0
Date: 1/7/2008
Time: 1:29:54 PM
User: N/A
Computer: My Computer
Description:
WindowsXYZServe r.GetSpace() Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED ))
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Question:
If I register a DLL as a certain path in my DEV system, say:
C:/x/y/z/library.DLL
and then I move the windows service to:
C:/a/b/c/
and put the DLLs in
C:/a/b/c/library.DLL
does that fudge up everything?
Must the path of the DLL files in the development
system match the path of the DLL files on the live server?
Thanks.

We can't help you if you don't tell us what the code is doing, only posting
a snippet that shows nothing isn't of any help.
From the above it looks like (suppose the eventlog entries have something to
do with the service) you are calling a COM server, for which the caller has
no access permissions. So, you'll have to adjust the Access Permissions for
the COM server using DCOMCNFG.

Willy.
Thanks Willy,

The code is writing to a number of text files.
The writing happens by calling a COM object which is a DLL reference
in the project.
Access to the COM objects is what is throwing the errors. I don't have
a COM server,
but COM DLLs in the same folder as the windows service.

How Do I prevent this error for COMs called locally?

Please let me know if you need other information otherwise, thanks for
your help.

Jan 7 '08 #8
Ignacio -

Thanks.

I tried your code and the start/stop error disappeared
but the service is still not working. I notice that when
I go to task manager i don't see myservice.exe in the
processes list.

I think this is due to access to my COM objects. How
is this resolved?

Thanks.
Jan 7 '08 #9
Your "COM dll's" are what Willy is referring to when he uses the
interchangeable term "COM server". Dcomcnfig can be used to adjust the Launch
permissions and remove the errors.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"pbd22" wrote:
On Jan 7, 2:19 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
"pbd22" <dush...@gmail. comwrote in message

news:81******** *************** ***********@k39 g2000hsf.google groups.com...
OK.
Went to the event logs and see all sorts of COM object access denied
errors.
Seems the DLLs I registered in the DEV environment are not firing when
I
move everything to the production server (my guess).
Example:
Event Type: Error
Event Source: My Source
Event Category: None
Event ID: 0
Date: 1/7/2008
Time: 1:29:54 PM
User: N/A
Computer: My Computer
Description:
WindowsXYZServe r.GetSpace() Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED ))
For more information, see Help and Support Center at
>http://go.microsoft.com/fwlink/events.asp.
Question:
If I register a DLL as a certain path in my DEV system, say:
C:/x/y/z/library.DLL
and then I move the windows service to:
C:/a/b/c/
and put the DLLs in
C:/a/b/c/library.DLL
does that fudge up everything?
Must the path of the DLL files in the development
system match the path of the DLL files on the live server?
Thanks.
We can't help you if you don't tell us what the code is doing, only posting
a snippet that shows nothing isn't of any help.
From the above it looks like (suppose the eventlog entries have something to
do with the service) you are calling a COM server, for which the caller has
no access permissions. So, you'll have to adjust the Access Permissions for
the COM server using DCOMCNFG.

Willy.

Thanks Willy,

The code is writing to a number of text files.
The writing happens by calling a COM object which is a DLL reference
in the project.
Access to the COM objects is what is throwing the errors. I don't have
a COM server,
but COM DLLs in the same folder as the windows service.

How Do I prevent this error for COMs called locally?

Please let me know if you need other information otherwise, thanks for
your help.

Jan 7 '08 #10

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

Similar topics

1
5434
by: Beeeeeves | last post by:
Hi, hope somebody can help... I have created a service which has a filesystemwatcher as its main component, it then logs information received in the events to an access database. I was using a setup project to install it, then attach to its process, very successfully for quite a while, I was almost thinking how well it was behaving - now whatever I do, whenver it starts it gives me a message along the lines of "the service started then...
0
4027
by: Eugene | last post by:
I have two window services that I created in C# and VB.net, one each, and set them to manual startup type. However, sometimes (not everytime) when I starts the service, an error message pops-up to say the service started and stopped automatically. ----------------------------------------------------------------------------------------------- The dicer service on Local Computer started and then stopped. Some services stop automatically if...
3
1410
by: Terry Olsen | last post by:
I have a windows service that has been running fine for almost 6 months. Last week, it just stopped working. It is still in the task list and still shows "started" in the service manager. There are no exceptions thrown, it just seems to have fell asleep. The service runs in a loop that checks about 80 servers on a daily basis to see what the status of the previous nights backup job is. It downloads the zipped log files from each...
6
2600
by: Christiano Donke | last post by:
Hey there... Plz... I'm writing a Windows Service that will check every x minutes if another program is running. If it cannot find the application running, it launches it... I had already enough trouble with make the timer tick... lol...
0
8808
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
9179
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
9077
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
7954
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
5959
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
4466
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...
1
3160
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
2
2525
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
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.