This is part of a series on creating and installing Windows services.
- Installation Service Internal Error 3utoolssmallbusinessever Error
- Installation Service Internal Error 3utoolssmallbusinessever Windows 10
- How to Handle Windows Service Errors
When you first login to a new Windows Server 2012 machine, the new Server Manager UI will display. Click Add roles and features. On the first screen of Add Roles and Features Wizard, click Next.This displays a page where you. Tech support scams are an industry-wide issue where scammers trick you into paying for unnecessary technical support services. You can help protect yourself from scammers by verifying that the contact is a Microsoft Agent or Microsoft Employee and that the phone number is an official Microsoft global customer service number.
In our firsttwo episodes, we saw that the Service Control Manager automatically logs service lifecycle events (start/stop) to the Windows Event Log. But, what happens if our service encounters an unexpected error and crashes during its run? We want to make it as easy as possible for our operations team to quickly identify the root cause of the problem.
To start, let’s build a service based on the infrastructure we have created over the past couple episodes. To test how our infrastructure reacts in the face of errors, we will intentionally make the service rather poorly behaved:
If we run this service from the console, you will notice that even without any special error handling in place, the exception is printed out to the console by the framework:
If you go ahead and install this service, we can experiment with how it behaves when running in service mode. If we start the service via services.msc, we get the following pop-up immediately:
And the service, as we would expect, did not start successfully. If we instead use
net start to start the service, we get the following message:
Notably, when using either method, the Service Control Manager isn’t really telling us anything useful about what happened, and it seems to not even know that there was an error during start-up. However, if we look at the event viewer, we notice that there is a useful error message there:
Apr 28, 2014 So I took a random unused service, changed its current account to be its virtual account (for example I took the aspnetstate service and set its logon to NT SERVICE aspnetstate) which added NT SERVICE All Services to log on as a service then set it back to whatever it was before. This got the all services account in log on as a service. 2013-08-30 08:22:15 Microsoft.UpdateServices.Administration.CommandException: Failed to start and configure the WSUS service at Microsoft.UpdateServices.Administration.PostInstall.Run at Microsoft.UpdateServices.Administration.PostInstall.Execute(String arguments) Fatal Error: Failed to start and configure the WSUS service. The Dell EMC PowerEdge R540 system is a 2U, dual socket rack system that supports up to. Two Intel Xeon Scalable Processors; 16 DIMM slots; Two AC and DC redundant power supply units (PSU) or single cabled PSU.
The framework has kindly gone ahead and logged the issue for us, even using the logger named after the service.
What happens if there is an unhandled exception thrown on a different thread? We know that those will tear down the application as well. Let’s experiment by modifying our misbehaving service to throw on a background thread instead of the main thread:
Repeating our experiments, we now see the following behavior when running from the console:
Which is pretty similar to what happened when we threw an exception on the main thread. When starting this service, we get the following slightly different (and more useful) message from services.msc:
And the following messages in the event viewer:
Unfortunately, none of these messages display the message associated with the exception that was thrown, although we do get the stack trace.
In both console mode and service mode, the framework already leaves a decent paper trail in the event of an unhandled exception. Any improvements we make should not eliminate this default behavior (by masking exceptions via
try/catch, for example).
There are three major shortcomings of the default behavior:
- In the event of an exception on the main thread during service start-up, the service controller does not seem to know that there was a failure, and reports a vague error.
- In the event of a background thread exception, the error written to the event log does not contain the exception message.
- We are not capturing fatal exceptions for the purpose of logging them to log4net (you are using log4net, right?)
Report start-up errors to the Service Control Manager
To handle this issue, we need to set the service’s ExitCode property to a non-zero value in the face of a start-up error. To do so, we must wrap our
OnStart method in a
I have chosen error 1064 : “An exception occurred in the service when handling the control request” because it seems to be the most appropriate (if anyone has a better idea of what we should set the error to, please leave a note in the comments). Also note that we re-throw the exception, thus preserving the existing behaviors (including the event logging) we saw above. If we start our service with this change in place, services.msc gives us a much more useful message, indicating that the service not only stopped, but failed:
Write background thread exception messages to the event log
To accomplish this goal, we need to attach to the current AppDomain’s UnhandledException event:
In our handler, we write a custom error message to the event log that will include the message associated with the exception (taking advantage of the default behavior of Exception.ToString). With this change, we will be able to see a bit more information in the event log when our service crashes due to an exception on a non-entry thread:
Log all errors to log4net
It is a good idea to log any error that takes down the application as a fatal error in our application logs. To accomplish this, we will need to add logging to both the error handlers we created above (both the
AppDomain.UnhandledException event handler and the
catch block in our
ServiceBase.OnStart method). We have to do both because an unhandled exception in
ServiceBase.OnStart is actually handled by the service controller and does not trigger firing of the
AppDomain.UnhandledException event. Adding logging calls to these two locations is left as an exercise to the reader.
Fixes are available
Rational Performance Test Server 8.7.1
Rational Integration Tester 8.7.1
Rational Test Virtualization Server 8.7.1
Closed as program error.
Reported component name
RATL PERF TEST
Reported component ID
Last modified date
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fixed component name
RATL PERF TEST
Fixed component ID
Applicable component levels
Installation Service Internal Error 3utoolssmallbusinessever Error
Installation Service Internal Error 3utoolssmallbusinessever Windows 10
07 October 2015