How to debug Windows Service startup.NET Tip of The Day.org

Actually you can use this trick every time when:

  1. You want to debug a process startup.
  2. You can't run the process by hitting Ctrl+F5 in Visual Studio (like Windows Service).

So the problem is that you can't simply attach the Visual Studio debugger to the process as there isn't one to attach to until after you start the process. However, once you start the process if you have a bug such as an exception in the process's initialization you won't get the debugger attached to the process before it's too late.

Calling Debugger.Launch() or Debugger.Break() in your code allow you to debug such problems. This methods pops up the following screen asking you which instance of the debugger it should use to debug the application.

JIT Debugger

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP Like Button Plugin by Free WordPress Templates