Testing for debug compilation mode, and debugging windows services in .Net

Just a quick post with a tip for those of you who are working on windows services.  You’ll probably come across the same problem I did some time ago when I first tried it – you can’t just click debug and step through a windows service, it has to be installed and run as a service outside the debugger.

A lot of sites and articles will tell you to use eventlogs and traces then as step debugging is impossible, or to try and manually hook into the process using “attach debugger to process”.  The first is just plain wrong, and the second a pain in the ass.  There is an easier way.

The answer lies in the System.Diagnostics.Debugger class, specifically it’s  static launch method.  Just add this to the start of your OnStart event:


and stick a breakpoint after it in your code.  Keep the ide open when you start the service and it will ask you to choose a debugger – giving the open ide as an option. Choose it and it will launch straight into a step by step of your source code.  Easy.

Of course, having that line in there is a pain when you want to release the service, so add a #if conditional to check the code. This ensures that the debugger launch command is included when the system is compiled in a debug configuration, and not when configured in release configuration.  The updated code is as follows:




This code will not even be included in the assembly when compiled outside of debug mode.

Two simple concepts of boundless value.  Enjoy. 🙂


I know from history the evils that nationalistic fervour can produce. It can cause good men to allow horrible atrocities to occur. The saying goes, all that is required for evil to triumph is for good men to do nothing, and nothing persuades good men to do nothing quite so strongly as nationalism.

But I watch a movie like 300 hundred and I am overawed by the power of it. You can feel their love for their country like a palpable thing, they literally can think of nothing greater than dying for it. It is a humbling thing. These Men, and they are not men but Men are amazing to watch.

Were the real Spartans like that? If anything, probably less cuddly. The story itself might not be true, of that I have no idea (but I doubt there was a giant fat man with swords for arms in the host of Xerxes), but much of the story is drawn from history. The Spartans really did kill any child they thought was misshapen or weakly, and the child rearing was much like was shown. If anything, less pleasant. It produced some of the strongest, most fearless warriors the world has ever seen who were utterly devoted to upholding their city state.

I think, just once, I would like to feel love like that. Such overwhelming pride. But not just feel it, feel it with reason. Every Spartan walked through hell to be ready to defend their country, and the lengths they went to – they had a right to feel pride. There is nationalism today, but it is based more on stupidity and brainwashing than anything to be really proud about.

Hell, maybe it was the same then, I don’t know. All I know is watching that movie makes me yearn to feel what they feel, instead of the shame I feel when I look at my own country and the decisions it is making, following the American culture in its decadent downward spiral into oblivion.

If you havn’t seen it, and you’re not squeamish at the sight of a little (lot) of blood, go see it. The battles are great, but the story itself stirs parts of the soul that are held deep within us, from a different time and world. A time when life was simpler perhaps, if infinitely shorter and more brutal.

Edit: Please note I don’t intend this post as an insult against Americans. I’ve met many of you that were great people. I rage instead against the culture of control, fear and FUD propagated by the American and Australian governments against their own people, doing their best to turn them into scared, controllable masses.  It is easy for scared people to become a herd, and herds can be driven to do things they wouldn’t normally do. Horrific things.  They will believe things that they wouldn’t normally believe.  As it was said in the movie “Men in Black”, A person is smart.  People are dumb. Kernals of truth can be found everywhere.

Since 9/11, including the people that were killed in 9/11, more people have been accidently killed by police officers in the United States than killed by terrorists.  Yet how many people are convinced, by the government, by the media, that terrorists lurk behind every corner. That fear gives the governments power to do things its people would normally never allow.  It’s not the terrorists you should be afraid of.


Well, yesterday I took another step in my continuing education and sat two exams for my course (Masters of Systems Development) that i’m doing by distance from Charles Sturt University.  One of the exams was a regular essay and short-answer university exam with the main difference being it was delivered through a prometric testing center. 

 A full half of my masters degree however is made up of microsoft certification exams however and I passed my first one yesterday, making my way into the hallowed halls of MCPdom, with a pass on .Net 2.0 Fundamentals.

 I’ve read a lot about certifications and people’s opinion seems to vary on how useful or valuable they are.  Its interesting though, I can say they are not a pushover. You really need to have studied and learnt a lot even to pass this first, foundation exam of the software developer line.  Its also interesting to note that the people who are the most vigourous attackers of certifications, microsoft ones in particular, don’t actually have any. Having not taken the exam and realised what it takes to pass it (particularly when working full time and doing another subject as well 😉 ), how on earth can you judge the value of it?

 Admittedly a certification isn’t proof of capability or talent, but it certainly shows a level of dedication that is often absent in our profession, where a lot of people think its fine to learn a few visual basic keywords and then call themselves a software developer.


Well, i’m out of hospital now after a laproscopic banding and slowly feeling better.  Occured to me that this means i’m now a cyborg, depending on your definition of the term. It’s not as complicated as a pacemaker or as glamourous as a science fiction type cybernetic arm or anything, but its still technology and its still been implanted in me.  I can feel part of it below the skin.  Freaky.

 S’all good now though and i’m looking forward to getting better as time goes on.  Things are looking up.