Re: .Net (C#) Service Fails To Start



One technique you could try if all else fails is to insert a try/catch block
around all of the code in your OnStart() method and show any errors in a
message box. Note this will require your service to have the "Interact With
Desktop" permission. Alternately, you could write the message to a known
file on disk.

--
Jared Parsons [MSFT]
jaredpar@xxxxxxxxxxxxxxxxxxxx
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Ken Allen" <kendrhyd@xxxxxxxxxxxx> wrote in message
news:eV3KMJjVFHA.4056@xxxxxxxxxxxxxxxxxxxxxxx
>I have a number of services developed in C# (.Net), and they have been
>working fine for the most part. Recently someone reported that ipon
>occassion (originally rarely, but more frequently on some systems of late),
>there is an entry in the Event Log immediately after a boot indicating that
>the service failed to start after 30,000 milliseconds. Usually it starts
>fine when attempting manually after the boot.
>
> I instrumented the code to write entries to the Event Log during its
> main() execution as well as during the OnStart() execution -- but when it
> fails, there are no entries in the Event Log from the service code!
>
> Attempting to launch the service as a console application always seems to
> succeed. Interestingly, launching as a console application is about 10
> times faster than starting the service! In no case that the service loaded
> properly did the time pass the 500 milliseond duration!
>
> I checked and there are no dependencies marked for the service. Is it
> possible that .Net is not available at that time and the service cannot
> execute?
>
> How can I define any dependencies at compile time? The ServiceInstaller
> permits me to define a list of services to depend on, but there does not
> seem to be any dependency on other objects. Nor does there appear to be
> any .Net service on which I could wait.
>
> Does anyone have any ideas on why my service may be failing to load, but
> only at boot time?
>
> Where does the /LogToConsole=false switch setting come from on my
> installed services? How do I change this to true, and what effect would
> that have on my service?
>
> -ken


.



Relevant Pages

  • Re: GAL.ResolveName issue with REDEMPTION
    ... This application updates appointments and tasks, ... but fails to send a mail to the receipient. ... where the execution fails. ... Debug.Print "RecipientIsValid" ...
    (microsoft.public.outlook.program_vba)
  • Re: Catastrophic failure
    ... Incrementing that Valiable while Inserting for Each dbf file. ... Step Execution Completed: 6/16/2004 7:47:43 PM ... I have used the above path 'H:\PA_Files\SRO' in the DTS Package while I ... Becuase my package fails by giviing the above error ...
    (microsoft.public.sqlserver.dts)
  • Re: Index causes INSERTs to fail
    ... > Is the insert a single record insert or an insert / select type operation? ... > Check execution plans ... > Some of this information would help narrow things down & avoid ... The statement actually never fails, ...
    (microsoft.public.sqlserver.server)
  • Re: CreateProcess FAILS
    ... Run depends.exe on the app. ... Look at what dependencies it has. ... those DLLs are in the build. ... How did you get this resolved, CreateProcess also fails for me. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: .Net (C#) Service Fails To Start
    ... Interesting technique - but when my code fails, it does not seem to even get that far, and when it succeeds, I have no need to debug it, and I cannot predict when it will fail. ... I checked and there are no dependencies marked for the service. ...
    (microsoft.public.dotnet.languages.csharp)

Loading