473,898 Members | 3,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specifying A Service Specific Error...

I am sure this has been asked at least once before but I could not find
anything when searching.

If I set the value of the ExitCode property to 1066 for a windows service,
the text "A service specific error occured: 0." How do I (if it is possible)
change the value of the zero to something custom (like a "look in the event
log for further information" message)?

Thank you,

Jason Richmeier
Oct 18 '06 #1
4 6814
Hi Jason,

Based on my understanding, you want to show some customized error from your
.net Windows Service application. Since you are referring to ExitCode
property, I am assuming you are using VS2005. Thanks.

First, I am not sure where do you want to show the customized erorr. In
Windows Service architecture, there are 2 processes: service process and
SCP process(which proivdes UI to the user and communicates with the service
process through any IPC technologies). Defaultly, Windows provided a
general style of SCP application services.msc as a MMC, so we normally use
this services.msc to manipulate the service applications. So my question is
do you want to show the customized error in standard services.msc or your
own written SCP application? To write a customized SCP application, we may
leverage ServiceControll er .Net class, please see the article below for
details:
"Communicat e With Windows Services"
http://msdn.microsoft.com/library/en...asp?frame=true

In my test project, I created a sample Windows Service application, with
the following simple code:
protected override void OnStop()
{
this.ExitCode = 100;
}

In services.msc, I clicked this deployed service and choose "Stop" command
to trigger the test code. The services.msc will report a dialog with the
error below:
"Error 100: Cannot create another system semaphore.". Is this what you
want? Note: the "Cannot create another system semaphore" string is the
win32 predefined error message for error code 100. So your application can
report any predefined win32 standard error through ExitCode property.

If you want to report something that is not specific to win32 predefined
error code, you should report it through
SERVICE_STATUS. dwServiceSpecif icExitCode field.(Note: SERVICE_STATUS is a
win32 SDK C++ structure which is encapsulated in .Net service classes, you
can look it in MSDN for more information). However, there is one problem
of using SERVICE_STATUS. dwServiceSpecif icExitCode field to report
customized failure:
"SERVICE_ST ATUS structure is encapsulated in .Net BCL, however, it is
marked as private and .Net did not provide any public property to
expose.(althoug h .Net provide ExitCode property to expose
SERVICE_STATUS. dwWin32ExitCode field), so it is impossible for us to use
this field in .Net code."

For testing purpose, I use VS2005 to debug my test Windows Service process,
and set a breakpoint in OnStop() method. When the execution breaks in
OnStop() method, I use the "Watch Window" to view "this.statu s" field,
which contains .Net encapsulated SERVICE_STATUS structure. In this window,
I modified dwWin32ExitCode to 1066L(ERROR_SER VICE_SPECIFIC_E RROR) and
dwServiceSpecif icExitCode to 100.(Yes, debugger can ignore the .Net
protection and change the memory directly)
I really will get the following dialog in services.msc:
"Windows could not stop the WindowsServiceE rrorReport on local computer.
For more information, review the System Event log. If it is a non-Microsoft
serivce, contact the service vendor, and refer to service-specific error
code 100"

I also got an error message in eventlog below:
"The WindowsServiceE rrorReport service terminated with service-specific
error 100 (0x64)."

So SERVICE_STATUS. dwServiceSpecif icExitCode really meets our need, however
it is not exposed by current .Net FCL.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 19 '06 #2
Thank you for all of the information.

Based on the information you provided, I was able to make a call to the
Win32 SetServiceStatu s call to specify the service specific exit code. It
took quite a bit of tinkering to get it to work (without error) but I think I
have finally got it working like I want.

Thank you,

Jason Richmeier

""Jeffrey Tan[MSFT]"" wrote:
Hi Jason,

Based on my understanding, you want to show some customized error from your
.net Windows Service application. Since you are referring to ExitCode
property, I am assuming you are using VS2005. Thanks.

First, I am not sure where do you want to show the customized erorr. In
Windows Service architecture, there are 2 processes: service process and
SCP process(which proivdes UI to the user and communicates with the service
process through any IPC technologies). Defaultly, Windows provided a
general style of SCP application services.msc as a MMC, so we normally use
this services.msc to manipulate the service applications. So my question is
do you want to show the customized error in standard services.msc or your
own written SCP application? To write a customized SCP application, we may
leverage ServiceControll er .Net class, please see the article below for
details:
"Communicat e With Windows Services"
http://msdn.microsoft.com/library/en...asp?frame=true

In my test project, I created a sample Windows Service application, with
the following simple code:
protected override void OnStop()
{
this.ExitCode = 100;
}

In services.msc, I clicked this deployed service and choose "Stop" command
to trigger the test code. The services.msc will report a dialog with the
error below:
"Error 100: Cannot create another system semaphore.". Is this what you
want? Note: the "Cannot create another system semaphore" string is the
win32 predefined error message for error code 100. So your application can
report any predefined win32 standard error through ExitCode property.

If you want to report something that is not specific to win32 predefined
error code, you should report it through
SERVICE_STATUS. dwServiceSpecif icExitCode field.(Note: SERVICE_STATUS is a
win32 SDK C++ structure which is encapsulated in .Net service classes, you
can look it in MSDN for more information). However, there is one problem
of using SERVICE_STATUS. dwServiceSpecif icExitCode field to report
customized failure:
"SERVICE_ST ATUS structure is encapsulated in .Net BCL, however, it is
marked as private and .Net did not provide any public property to
expose.(althoug h .Net provide ExitCode property to expose
SERVICE_STATUS. dwWin32ExitCode field), so it is impossible for us to use
this field in .Net code."

For testing purpose, I use VS2005 to debug my test Windows Service process,
and set a breakpoint in OnStop() method. When the execution breaks in
OnStop() method, I use the "Watch Window" to view "this.statu s" field,
which contains .Net encapsulated SERVICE_STATUS structure. In this window,
I modified dwWin32ExitCode to 1066L(ERROR_SER VICE_SPECIFIC_E RROR) and
dwServiceSpecif icExitCode to 100.(Yes, debugger can ignore the .Net
protection and change the memory directly)
I really will get the following dialog in services.msc:
"Windows could not stop the WindowsServiceE rrorReport on local computer.
For more information, review the System Event log. If it is a non-Microsoft
serivce, contact the service vendor, and refer to service-specific error
code 100"

I also got an error message in eventlog below:
"The WindowsServiceE rrorReport service terminated with service-specific
error 100 (0x64)."

So SERVICE_STATUS. dwServiceSpecif icExitCode really meets our need, however
it is not exposed by current .Net FCL.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 19 '06 #3
Hi Jason,

Yes, if I did not misunderstand you, you have declared a customized
SERVICE_STATUS structure in .Net and p/invoked SetServiceStatu s to set the
dwServiceSpecif icExitCode member for reporting error. Yes, I think this
will work.

It seems that my mind is blocked to believe that we must use the
SERVICE_STATUS structure stored in "ServiceBase.st atus" field for status
updating. This is not the case. We certainly can create a new
SERVICE_STATUS structure for SetServiceStatu s API :-). Thank you for
pointing this out.

If you need further help, please feel free to post, thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 20 '06 #4
Additionally, you should write a customized SCP application to recognize
the service specific error reported by your service, since services.msc can
not understand such specific error.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 20 '06 #5

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

Similar topics

2
6725
by: jmlynn | last post by:
Help! I installed MySQL 4.0.20C and it works if I started it with mysqld --console However, if I do the following: mysqld --install net start MySQL
0
1057
by: GTS | last post by:
Hi, I have created my application to run as windows service. It is developed using VC++ on Windows 2000 platform. It is working fine with Windows 2000. But I am seeing problems in Windows 2003 while stopping the service. Is there any specific change needed to run it on Windows 2003. Thanks
3
2512
by: THNQDigital | last post by:
Hi All, I have written VB.NET Windows Service whcih reads some information from Outlook and creates an Excel report outa it. When i make a console application and run the program everything works fine but same code does not work if i put it in an Windows service. My OS : Win2000 Pro
2
16383
by: Madhu | last post by:
Hello All, I am getting the below error message when I am trying to connect from client to remote database server installed on Linux. DB2 UDB ESE database is running on a trail version on Linux and client (administration client) installed on Windows. #_____________________________________________________________________ Protocol specific error code(s): "10065", "*", "*". SQLSTATE=08001
6
8700
by: Joe | last post by:
C# .NET 2.0 I've got a Windows Service that works exactly as I expect it to. However, it does rely on a few Configuration settings. If the customer doesn't configure it correctly, the service shouldn't start. So I've put in some try...catchs, but what I'm not sure how to do is not allow the service to start. If attempted to start with the NET START command, throwing an exception keeps the service from starting, but the message...
2
4001
by: maansi.creations | last post by:
Service unavailable error comes randomly while accessing our website and gets alright in matter of seconds....Could some one tell the possible reasons for these to happen: i got a earlier suggestion to our error as follows: ------------------------------------------------------- If the error continues, it means that your website is exceeding the resource thresholds we set in IIS. Your website has been allocated 20% CPU and 800 MB of...
2
9414
by: Brent Halsey | last post by:
I am using the ibm_db2 PECL drive in PHP for connecting to or DB2 database. I created a persistent connection and things seemed to work fine at first. However, after a few tests / connections, I started to get this error when running through my queries: SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected:...
4
48824
by: Pool | last post by:
I tried to connect DB2 (Sitting in Unix server at my client location) using Db2 connect V8. I am getting the following error message. I tried all the possible options BUt the error is same.. See each type belpw Standard connection failed.
1
7845
by: johnyjj2 | last post by:
Hello! I've got web application created for MSSQL and IIS. There are two directories in this application - Scripts and WebSite. In Script there is file CreateDb.sql. I need to run it so that it can create database. I changed in that file one line into this: CREATE DATABASE ON PRIMARY ( NAME = N'NameOfDb', FILENAME = N'F:\Inetpub\wwwroot\htdocs\WebSite\NameOfDb.mdf' and the other part for the same directory but other filename...
0
9994
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
11265
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
10488
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
9662
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
7191
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
6079
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4712
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
4298
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3309
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.