473,494 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

My NT Services crash at startup (1 out of 10 time)

On all my Windows Services (written in C# and for some of them in MC++), I
got from time to time crashes at startup (1 out of 10 startup). It occurs
really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
The instruction at "0x791cfea1" referenced memory at "0x00000050". The memory could not be "read".Click on Ok to Terminate
Click on Cancel to Debug

I do suspect that this may occurs in one of my common assemblies. Probably
in some static member/class initializations.
What I did is to try to place suspect static initializations in a class
initializer and place them within a try/catch sections.

I tried to start the service as a normal program (according to description
shown in MSDN). However, it works ok this way.
Here are my questions:

- If I place a try/catch section in a class initializer, will the catch be
hit in case of problem?
- How could I point out to the location where the problem occured using the
error message shown
- Is it possible to debug the application?
If I press Cancel, DrWatson generates a log. I would like to run JIT
debugger instead
Any help greatly appreciated!!!
José

Nov 15 '05 #1
7 2607
Some ideas:

You could put some EventLog.WriteEntry entries in your common assemblies just to try and pinpoint the problem.
Also, make sure that none of your common assemblies inadvertently does any UI.
Verify this by setting the service to 'Allow interaction with desktop' and running the service.

Also; there was a bug in v1.0 of the framework, not sure if it's in v1.1, where services couldn't start if
the eventlog is full. Try clearing the eventlog and see if it helps.

--
Robert Jeppesen
robert.jeppesen%at%durius-dot-se
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message news:ud**************@tk2msftngp13.phx.gbl...
On all my Windows Services (written in C# and for some of them in MC++), I
got from time to time crashes at startup (1 out of 10 startup). It occurs
really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
The instruction at "0x791cfea1" referenced memory at "0x00000050". The memory could not be "read".Click on Ok to Terminate
Click on Cancel to Debug

I do suspect that this may occurs in one of my common assemblies. Probably
in some static member/class initializations.
What I did is to try to place suspect static initializations in a class
initializer and place them within a try/catch sections.

I tried to start the service as a normal program (according to description
shown in MSDN). However, it works ok this way.
Here are my questions:

- If I place a try/catch section in a class initializer, will the catch be
hit in case of problem?
- How could I point out to the location where the problem occured using the
error message shown
- Is it possible to debug the application?
If I press Cancel, DrWatson generates a log. I would like to run JIT
debugger instead
Any help greatly appreciated!!!
José

Nov 15 '05 #2
Thanks for the tips.

Sorry for information I missed:

- I currently write into the EventLog as fallback in my tracing routines.
- I already allowed interaction with the Desktop to see if I can get extra
info
- I have set the overwrite eventlog flag (so it will not get full).

Thanks anyway!
José

"Robert Jeppesen" <robert.jeppesen(#)durius.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Some ideas:

You could put some EventLog.WriteEntry entries in your common assemblies just to try and pinpoint the problem. Also, make sure that none of your common assemblies inadvertently does any UI. Verify this by setting the service to 'Allow interaction with desktop' and running the service.
Also; there was a bug in v1.0 of the framework, not sure if it's in v1.1, where services couldn't start if the eventlog is full. Try clearing the eventlog and see if it helps.

--
Robert Jeppesen
robert.jeppesen%at%durius-dot-se
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message

news:ud**************@tk2msftngp13.phx.gbl...
On all my Windows Services (written in C# and for some of them in MC++), I got from time to time crashes at startup (1 out of 10 startup). It occurs really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
>The instruction at "0x791cfea1" referenced memory at "0x00000050". The

memory could not be "read".
>Click on Ok to Terminate
>Click on Cancel to Debug

I do suspect that this may occurs in one of my common assemblies. Probably in some static member/class initializations.
What I did is to try to place suspect static initializations in a class
initializer and place them within a try/catch sections.

I tried to start the service as a normal program (according to description shown in MSDN). However, it works ok this way.
Here are my questions:

- If I place a try/catch section in a class initializer, will the catch be hit in case of problem?
- How could I point out to the location where the problem occured using the error message shown
- Is it possible to debug the application?
If I press Cancel, DrWatson generates a log. I would like to run JIT
debugger instead
Any help greatly appreciated!!!
José


Nov 15 '05 #3
You can attach to the process from within Visual Studio. It's in the debug menu.
Since your service causes a crash in the constructor, start the constructor with
a Thread.Sleep(15000); This will give you time to attach to the process before it crashes.
Also, if the service crashes within 15 seconds, you'll know that it''s probably an initialization in
a variable declaration that is crashing, because such initializasions get compiled in the start of the constructor.

--
Robert Jeppesen
robert.jeppesen%at%durius-dot-se
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message news:%2***************@TK2MSFTNGP10.phx.gbl...
Thanks for the tips.

Sorry for information I missed:

- I currently write into the EventLog as fallback in my tracing routines.
- I already allowed interaction with the Desktop to see if I can get extra
info
- I have set the overwrite eventlog flag (so it will not get full).

Thanks anyway!
José

"Robert Jeppesen" <robert.jeppesen(#)durius.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Some ideas:

You could put some EventLog.WriteEntry entries in your common assemblies

just to try and pinpoint the problem.
Also, make sure that none of your common assemblies inadvertently does any

UI.
Verify this by setting the service to 'Allow interaction with desktop' and

running the service.

Also; there was a bug in v1.0 of the framework, not sure if it's in v1.1,

where services couldn't start if
the eventlog is full. Try clearing the eventlog and see if it helps.

--
Robert Jeppesen
robert.jeppesen%at%durius-dot-se
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message

news:ud**************@tk2msftngp13.phx.gbl...
On all my Windows Services (written in C# and for some of them in MC++), I got from time to time crashes at startup (1 out of 10 startup). It occurs really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
>>The instruction at "0x791cfea1" referenced memory at "0x00000050". The
memory could not be "read".
>>Click on Ok to Terminate
>>Click on Cancel to Debug
I do suspect that this may occurs in one of my common assemblies. Probably in some static member/class initializations.
What I did is to try to place suspect static initializations in a class
initializer and place them within a try/catch sections.

I tried to start the service as a normal program (according to description shown in MSDN). However, it works ok this way.
Here are my questions:

- If I place a try/catch section in a class initializer, will the catch be hit in case of problem?
- How could I point out to the location where the problem occured using the error message shown
- Is it possible to debug the application?
If I press Cancel, DrWatson generates a log. I would like to run JIT
debugger instead
Any help greatly appreciated!!!
José



Nov 15 '05 #4
José Joye wrote:
On all my Windows Services (written in C# and for some of them in MC++), I
got from time to time crashes at startup (1 out of 10 startup). It occurs
really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
The instruction at "0x791cfea1" referenced memory at "0x00000050". The
memory could not be "read".
Click on Ok to Terminate
Click on Cancel to Debug


You may have a bad memory module also. Does this happen on only one
computer or on a number of them?
Nov 15 '05 #5
Hello,

This happens on high speed (4 CPUs) computers. I really suspect
initialization problem.

José

"James Black" <jb****@ieee.org> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl...
José Joye wrote:
On all my Windows Services (written in C# and for some of them in MC++), I got from time to time crashes at startup (1 out of 10 startup). It occurs really at the time I click on the "Start service" button.

I have try/catch sections all around, and also have defined an
"UnhandledExceptionEventHandler" in the ctor of the Service Main().
I'm still not able to catch what is going on :-((

The error is:
The instruction at "0x791cfea1" referenced memory at "0x00000050". The


memory could not be "read".
Click on Ok to Terminate
Click on Cancel to Debug


You may have a bad memory module also. Does this happen on only one
computer or on a number of them?

Nov 15 '05 #6
José Joye wrote:
Hello,

This happens on high speed (4 CPUs) computers. I really suspect
initialization problem.


This code snippet may help you out. I use this to be able to switch
from running as a service to running the application in a debugger.
Obviously 'runasService' is a boolean type.
By running it in a debugger you may be able to figure out what is
going on.

// The main entry point for the process
static void Main(String[] args)
{
// Creates an instance of the methods that will handle the exception.
//CustomExceptionHandler eh = new CustomExceptionHandler();

// Adds the event handler to to the event.
//Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);

if (runAsService)
{
System.ServiceProcess.ServiceBase[] ServicesToRun;

// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = New System.ServiceProcess.ServiceBase[] {new
Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
LabLoginService() };

System.ServiceProcess.ServiceBase.Run(ServicesToRu n);
}
else
{
LabLoginService service = new LabLoginService();
service.OnStart(args);
}
}

Nov 15 '05 #7
Thanks,

I will try it

José
"James Black" <jb****@ieee.org> wrote in message
news:OB****************@TK2MSFTNGP12.phx.gbl...
José Joye wrote:
Hello,

This happens on high speed (4 CPUs) computers. I really suspect
initialization problem.


This code snippet may help you out. I use this to be able to switch
from running as a service to running the application in a debugger.
Obviously 'runasService' is a boolean type.
By running it in a debugger you may be able to figure out what is
going on.

// The main entry point for the process
static void Main(String[] args)
{
// Creates an instance of the methods that will handle the exception.
//CustomExceptionHandler eh = new CustomExceptionHandler();

// Adds the event handler to to the event.
//Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);

if (runAsService)
{
System.ServiceProcess.ServiceBase[] ServicesToRun;

// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = New System.ServiceProcess.ServiceBase[] {new
Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
LabLoginService() };

System.ServiceProcess.ServiceBase.Run(ServicesToRu n);
}
else
{
LabLoginService service = new LabLoginService();
service.OnStart(args);
}
}

Nov 15 '05 #8

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

Similar topics

699
33308
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
1
1392
by: Michele Simionato | last post by:
There are situations in which you have to setup a faily sophisticated environment before running your tests. This may result in a long startup time. In my case (using PloneTestCase) the time taken...
16
5739
by: Neil Benn | last post by:
Hello, I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python...
1
1691
by: Stanislaw Tristan | last post by:
It's 3 files: App.exe 3rdParty1.dll 3rdParty2.dll I can't find really examples in MSDN Please, if possible, step-by-step instructions how with Ngen make loading faster in a some user machine....
1
1126
by: Martin Altemark | last post by:
I have this webapplication, and when unloaded in the webserver because of session timeouts there is a huge difference in the startup times between my own developer computer and the web server it's...
2
1387
by: Sheila | last post by:
Hi, I published a web service and tested working fine when calling this web service from a windows application. The web service reference URL is defined in web service properties. Now I want the...
4
2025
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is it typical for an 2.0 application take 15 - 20 seconds to start up, after a long period of inactivity? If not, what can I look at to get it to start quicker, the first time it is used?
0
1357
by: uonedang | last post by:
Hi folks, In Linux, when an application is started up .. and its dependent shared libraries are loaded into memory automatically at startup time ... I wonder what part of kernel/OS determines and...
0
7119
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,...
0
6989
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...
0
7157
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,...
0
7195
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...
0
5453
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,...
1
4889
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...
0
4579
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...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
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...

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.