473,614 Members | 2,328 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 2615
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
33825
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
1399
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
5764
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
1704
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
1134
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
1396
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
2032
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
1363
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
8198
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
8142
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
8642
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...
1
8294
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
8444
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
4058
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
2575
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
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
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.