473,545 Members | 1,550 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 6796
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
6692
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
1044
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
2497
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
16338
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...
6
8683
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...
2
3985
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...
2
9361
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:...
4
48703
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
7827
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 =...
0
7651
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. ...
0
7802
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...
1
7410
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...
1
5320
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4941
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...
0
3443
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...
0
3438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
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
1010
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.