473,847 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ 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
"UnhandledExcep tionEventHandle r" 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 2625
Some ideas:

You could put some EventLog.WriteE ntry 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*******@KILL THESPAMSbluewin .ch> wrote in message news:ud******** ******@tk2msftn gp13.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
"UnhandledExcep tionEventHandle r" 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.jeppese n(#)durius.se> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Some ideas:

You could put some EventLog.WriteE ntry 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*******@KILL THESPAMSbluewin .ch> wrote in message

news:ud******** ******@tk2msftn gp13.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
"UnhandledExcep tionEventHandle r" 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(15 000); 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*******@KILL THESPAMSbluewin .ch> wrote in message news:%2******** *******@TK2MSFT NGP10.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.jeppese n(#)durius.se> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Some ideas:

You could put some EventLog.WriteE ntry 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*******@KILL THESPAMSbluewin .ch> wrote in message

news:ud******** ******@tk2msftn gp13.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
"UnhandledExcep tionEventHandle r" 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
"UnhandledExcep tionEventHandle r" 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.or g> wrote in message
news:eB******** ******@TK2MSFTN GP12.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
"UnhandledExcep tionEventHandle r" 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.
//CustomException Handler eh = new CustomException Handler();

// Adds the event handler to to the event.
//Application.Thr eadException += new
ThreadException EventHandler(eh .OnThreadExcept ion);

if (runAsService)
{
System.ServiceP rocess.ServiceB ase[] 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.ServiceP rocess.ServiceB ase[] {new
Service1(), new MySecondUserSer vice()};
//
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
LabLoginService () };

System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}
else
{
LabLoginService service = new LabLoginService ();
service.OnStart (args);
}
}

Nov 15 '05 #7
Thanks,

I will try it

José
"James Black" <jb****@ieee.or g> wrote in message
news:OB******** ********@TK2MSF TNGP12.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.
//CustomException Handler eh = new CustomException Handler();

// Adds the event handler to to the event.
//Application.Thr eadException += new
ThreadException EventHandler(eh .OnThreadExcept ion);

if (runAsService)
{
System.ServiceP rocess.ServiceB ase[] 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.ServiceP rocess.ServiceB ase[] {new
Service1(), new MySecondUserSer vice()};
//
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
LabLoginService () };

System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}
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
34366
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 capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
1
1405
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 to import all the needed libraries, create a plone site and set up the environment, is so long that practically I cannot use my good old Pentium II for running the test cases. Notice that the problem is not in the time spent on the
16
5798
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 interpreter to start up very quickly (<1 second on a Windows box). Is there a way to have a 'stripped' down Python interpreter which can start up very quickly on a windows box. Once thing I was thinking of was to use PyExe to make a quick startup (does...
1
1716
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. Thanks!
1
1140
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 intended for. On my own computer it loads and executes in about 2-3 seconds when it's more like 12-13 seconds on the web server. How can this be? The computers a similar in configuration hardware-wise. I'm getting crazy with this now - please...
2
1402
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 application to dynamically access the Webservices at run time. I tried changing the web service url in app.config file but it doesn't work. Does anybody know what could be the reason. Is there any other way to do it. Thanks in advance.
4
2039
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
1374
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 loads these shared libraries into memory ... Thanks Dang
0
9734
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
10991
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
10653
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...
0
10347
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
9490
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
7061
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
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
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
4129
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.