Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Windows Service App

Windows Service App

Scheduled Pinned Locked Moved C#
helpcom
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japanreddy
    wrote on last edited by
    #1

    I have written an application that runs on Windows Service. It runs fine (I overcame some of the problems I had with it earlier). It does perfectly everything that it is supposed to do - the only problem - after I start the service it runs for about a day or two and it halts (stops) by itself in the middle of the night. When I see it is stopped, I restart it and it gets back to its normal operation. I have to keep watching until it stops again. Is there known issue that can resolve this problem. Help would be highly appreciated. (vinayakkatkam@yahoo.com). Vinayak Katkam

    H X 2 Replies Last reply
    0
    • J japanreddy

      I have written an application that runs on Windows Service. It runs fine (I overcame some of the problems I had with it earlier). It does perfectly everything that it is supposed to do - the only problem - after I start the service it runs for about a day or two and it halts (stops) by itself in the middle of the night. When I see it is stopped, I restart it and it gets back to its normal operation. I have to keep watching until it stops again. Is there known issue that can resolve this problem. Help would be highly appreciated. (vinayakkatkam@yahoo.com). Vinayak Katkam

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      What problem? You didn't give a specific problem and we know nothing about your code so how can we diagnose it? If you want to know what is happening with your service, you need to debug it. Since this problem takes a while to occur, the best way to debug it is to instrument it. The most basic way is to use the Trace facilities in System.Windows.Forms using the EventLogTraceListener. You can configure this progammatically or using the .config file for your Windows Service (which I recommend, since you can change it at runtime). Throughout your code, use Trace.WriteLine to log state and events in a reasonable way so that when a problem occurs you can determine either what happened or in what part of your code the problem happened. In your .config file (named the same as your application + .config and in the same directory, like MyServiceApp.exe.config), write something like this:

      <configuration>
      <system.diagnostics>
      <trace>
      <listeners>
      <add type="System.Diagnostics.EventLogTraceListener, System"
      initializeData="Application" />
      </listeners>
      </trace>
      </system.diagnostics>
      </configuration>

      Then whenver you use Trace.Write or Trace.WriteLine (or even the corresponding methods on the Debug class, which is only compiled into your IL if the DEBUG symbol is defined by the compiler) the message will appear in the trace log (use eventvwr.exe to view it). There are other, more complex (and better) ways of instrumenting your application but this is by far the easiest. It's a good place to start, especially since you gave us no specifics with which we can help you.

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • J japanreddy

        I have written an application that runs on Windows Service. It runs fine (I overcame some of the problems I had with it earlier). It does perfectly everything that it is supposed to do - the only problem - after I start the service it runs for about a day or two and it halts (stops) by itself in the middle of the night. When I see it is stopped, I restart it and it gets back to its normal operation. I have to keep watching until it stops again. Is there known issue that can resolve this problem. Help would be highly appreciated. (vinayakkatkam@yahoo.com). Vinayak Katkam

        X Offline
        X Offline
        Xiangyang Liu
        wrote on last edited by
        #3

        In addition to Heath's useful suggestions, here is an alternative. 1. Write your code in a regular console/windows application, run and debug your code from the Visual Studio debugger (set break points at places where failures occur). 2. When it is "bug free", run it from XYNTService[^]. If you cannot figure out the bug but you have to deploy your app anyway, then you can use XYNTService to restart your app whenever it fails. Read the above article for details. P.S. I understand this may not be a good solution under all circumstances.[

        My articles and software tools

        ](http://mysite.verizon.net/XiangYangL/index.htm)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups