views:

28

answers:

2

I'm trying to write a windows service. It installs fine, but fails when I run it with the following exception. I've searched for the string "MyNewProgramService", but I can't find any conversions that would throw this error. I've also added try/catch blocks to a bunch of code with custom exception handling without finding where this exception is occuring. I'm thinking it's somewhere in the auto-generated configuartion/setup code. Any ideas?

Event Type: Error 
Event Source:   MyNewProgram Event 
Category:   None Event 
ID: 0 
Date:       4/15/2010 
Time:       12:48:34 PM 
User:       N/A 
Computer:   20F7KF1 
Description: Service cannot be started. System.InvalidCastException: 
Conversion from string "MyNewProgramService" to type 'Integer' is not valid. --->
System.FormatException: Input string was not in a correct format.    
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value,
     NumberFormatInfo NumberFormat)  
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)    
     --- End of inner exception stack trace --- 
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at TaskManagerFailureHandlerService.MyNewProgramService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
A: 

Check your configuration file.

You might also check the account the service is running as. Just as a test go to the login tab in the services list and have it login under your own account. If the problem vanishes it's a permissions problem.

Jay
+2  A: 

it falls in method MyNewProgramService.OnStart, there Conversions.ToInteger is called somewhere. Just search for it in method. Then check parameter. It might come from config or something, thats why you don't see string in text.

Andrey
Thank you so much. I had a parameter swapped around in a call I was making from the exception handler in the OnStart method. (One error masking another, what I pain!) Thanks for getting me onto the right track!
Jeff