Debugger.Launch() in Services on Windows 8

by Runar Ovesen Hjerpbakk

I tried debugging (sorry Uncle Bob) a regular Windows service on Windows 8.1 the other day. As so many times before, I started with adding Debugger.Launch() in the beginning of the service, compiled it under Debug, copied the DLLs and started the service.

In Windows 7, the JIT debugger selection popup would then appear, and the correct instance of Visual Studio could be selected to perform the debugging session. This time though, nothing.

As always when nothing happens in Windows, I checked the event viewer.

Event Viewer

An unhandled Microsoft .NET Framework exception occurred in WindowsService.Server.exe [6652]. Just-In-Time debugging this exception failed with the following error: The operation attempted is not supported.

Check the documentation index for 'Just-in-time debugging, errors' for more information.

So I did.

The Solution

You need to change a registry key to enable debugging of a Session 0 process (like a windows service) on Windows 8. The Visual Studio JIT Debugger has its AppIDFlags set to APPIDREGFLAGS_IUSERVER_ACTIVATE_IN_CLIENT_SESSION_ONLY (0x20) and APPIDREGFLAGS_IUSERVER_UNMODIFIED_LOGON_TOKEN (0x8), thus preventing debugging.

Change the key to 0x8 by running the following command:

reg add "HKCR\AppID{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 8 /f

When your code works and you never want to debug again, restore the default value 0x28 by running:

reg add "HKCR\AppID{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 40 /f

There's No Excuse

by Runar Ovesen Hjerpbakk

Via DaedTech:

What’s the moral of this story? To me, it’s this: if you have a giant document detailing manual steps for programmers to follow to get something done, what you really have is a spec/user story for your next development cycle. Automate all the things, and then burn those documents at a cathartic, gleeful camp fire. You can turn your onerous processes into roasted marshmallows.

This XKCD is relevant.

And this one.

Arnold Schwarzenegger based programming language

by Runar Ovesen Hjerpbakk

Lauri Hartikka presents ArnoldC.

Although the one-liners of Arnold Schwarzenegger are fairly well known the true semantics of the uttering is yet to be understood. This project tries to discover new meanings from the Arnold movies with the means of computer science.

Finally a proper manly language.

Also relevant: