Sunday, November 27, 2005

Triple Whammy

It's been a bit quiet around here, but there's been good reason. As you know, my friend Alex got hit by a car. The next weekend, I sliced my thumb up with a table saw. Well, the weekend after that, the worst of the lot happened: I got a call from one of my brothers telling me that my dad had lost consciousness while returning from a vacation.

 

They say things happen in threes, and I certainly hope that's true, because after this one I'm ready for a break from hospitals. It turns out that my dad had an abdominal aortic aneurysm (a "triple A"). Briefly, this means that the large artery that leads downward from his heart had weakened and swelled. I saw the CT scan at one point: it was roughly the size of an American football.

 

My dad got lucky on several counts. To start with, he'd just traded places with my mom when he passed out, so he wasn't driving. That could easily have killed them both. On top of that, even though they were in northern Minnesota (which is basically the middle of nowhere), they happened to be near a hospital, so the ambulance was able to get him to a doctor quickly. And the doctor was good enough to get the diagnosis right and immediately put my dad on a helicopter for a hospital in Duluth. And the vascular surgeon in Duluth managed to repair my dad's artery, saving his life. Dad's blood pressure dropped to zero at one point, so it was a near thing.

 

The whole family descended on Duluth, of course. Dad was in the ICU for a week, but has since been transferred to the cardiac recovery unit. He's still in Duluth, but the rest of the family has started returning to their homes now that the largest dangers are past. We're all hoping that he'll be home by Christmas when we all return, although it's no sure thing.

 

One of the worst parts about the whole process was that my dad was so completely looped by the drugs and the shock and the sleep deprivation that he was basically delirious until about nine days after the surgery. And it wasn't until about eight days out that anyone was able to tell us it wasn't a stroke. It was pretty hard on my mom to hear my dad basically babbling nonsense about how he wasn't really in a hospital. Fortunately, sleep and changes of medication fixed that up and dad is now as sharp as ever.  

 

We spent the Thanksgiving holiday there in a hotel. My wife and my brother did a bang-up job of whipping up a first-rate giant meal using only a microwave and what they could find at the grocery store on Thursday afternoon. Still, I can certainly think of better ways to spend the holiday. But I can much more easily think of worse ways.

 

Here's hoping my next post talks about something boring like what I'm working on over at MSDN.

Thursday, November 10, 2005

Don't Argue With Power Tools

I think maybe the hospital I live near should build a tunnel from my basement to the ER. It's only about two blocks anyway, and I've walked over there four times in the last two weeks. The first three times were to visit my friend Alex, who got hit by a car. This latest time, though, was all me. Nothing quite so serious, but nonetheless not an experience I hope ever to repeat.

 

I was in my basement on Sunday, working on building a bench for my new planer. I've been buying a lot of tools lately, and it's starting to get a bit crowded down there, so I figured I'd work on some storage. So I was running a 2x4 through the table saw to cut it down to size.

 

I'm not entirely sure what happened next. My memory is a bit hazy for those few seconds. But I think I was concentrating on keeping one of my hands away from the blade, and didn't pay quite enough attention to the other. What I do remember pretty clearly is jumping away from the saw, yelling loudly, and clutching my thumb.

 

Before I go too much further, let me say that I did not sever any digits. I gave myself a really nasty cut across the pad of my thumb, but I didn't slice anything completely off. I'd say it's about a five or six on a scale of one to ten, where one is a paper cut, and ten is the aforementioned digit removal. The nurse at the ER (where I spent the next four hours) gave me an "A+", though. :p

 

Here's a picture of the rather nifty bandage they gave me.

 


 

They had to put it on with a special tool - it was sort of a cage that stretched a tubular piece of gauze out, and they fed it up and down, creating layers. Very clever, I thought.

 

If you want to see what it looks like underneath the bandage, well, what's wrong with you?!? :) But click here and check it out if you must. Warning to those with a weak stomach: it's gross. Warning to those with a highly developed photoaesthetic sense: the picture is poorly taken.

 

Anyway, it looks like I'll heal up in a few weeks. Right now, I can't feel the tip of my thumb, but I'm hoping that will come back. In the meantime, it hasn't interfered with my typing too much, and that's the important thing, since it's how I earn my bread.

 

The weirdest thing about the whole experience has been observing the mental and physical effects. I've never really hurt myself seriously before, so it was odd to feel myself going through the typical reactions. First was physical shock - I was disoriented and sweating for a few minutes right after. And then of course there was disbelief ("there's no way I just turned my thumb into a tiny pile of hamburger!"), anger (as I was walking to the ER I was super pissed that I'd been so stupid), depression (not the real kind, but I was a little down about it for a bit), etc.

 

All in all I'd say I was dumb but lucky. Which beats dumb and unlucky or even smart and unlucky. In the future I'm hoping to be smart and lucky. I also hope to return to amateur carpentry (sans the amateur surgery), but one thing I'm not sure about yet is whether this whole incident has dampened my enthusiasm to the point where I'll just find something else to do any time it's time to turn on the power tools. But if I do go back to it (as I intend to), I know this: I'm going to incorporate the piece of wood that I was cutting into the final product. Preferably with the bloodstain showing. Just something from my own twisted sense of revenge I guess. Or stubbornness.

 

So, woodworkers: be careful out there. Pay attention, build or buy whatever jig you need to make the cut safely, and think before you act.

 

Oh, and if you see my parents, don't tell them. :)

Friday, November 4, 2005

My New Favorite VS2005 Key Sequence

Another one in the "I might be the last one to figure this out" department. But it's cool, so I want to share it.

 

I'm a keyboard guy. That's why I love discovering new shortcuts. Today, when working in VS2005, I accidentally hit ctrl-alt-down arrow. So I was surprised when up popped a scrollable list of my open windows. You can even type the first few letters of the filename to navigate the list. I like it better than ctrl-tab when I know the name of the window I want to open, because it doesn't make me visually scan a big unordered list. When I know I want the last window, or the one before that, ctrl-tab still wins.

Thursday, November 3, 2005

What Has Craig Been Working On?

The other day I told you about some of the things that have been up in my personal life. I also said I'd post about what I've been doing for work. Ah - the classic blogger conceit: the surety that you care. :)

 

At any rate, right now I have four projects going simultaneously. Balancing them has, at times, been tricky, but so far I've managed to keep all of them moving forward without having to work nights or weekends. (Wife in school plus toddler means I couldn't really do that anyway.) I'll describe each of them briefly.

 



  1. e.POWER 2005. For the last three years, I've been helping my client Integic port part of their e.POWER workflow product to .NET. At the same time we move existing functionality, we've also been adding a web services façade, with the obvious goal of making it easier to integrate e.POWER workflow services into their applications. I've been acting as an architectural consultant, advising on how to design and implement the system, but I also wrote big chunks of the security system, pretty much all of the database access library, and pretty much all of the build system, as well as a bunch of other bits and pieces. We're nearly ready to ship it, and I'm eager to see what happens when the bits go into action at a real, live customer. I think the answer is "good things", but the proof is in the pudding.

  2. FlexWiki. No surprise here - if you read this blog, you know that I've been doing a massive refactoring of the FlexWiki codebase, which includes a port to .NET 2.0. The end goal is to implement good application-level security in FlexWiki, but to do that I'm going to wind up rewriting most of the core of FlexWiki. When I'm done, I hope it'll be much more extensible and quite a bit less tangled than it is now. Since no one's paying me to do this one, it has the lowest priority, but I'm still trying to devote an hour to it every day, with the hope that I can get something back into the community some time in early 2006. We'll see how I do on that one.

  3. Pluralsight's Applied .NET Architecture & Design Course. The sharp-eyed have noticed that Pluralsight have announced several new courses, among them mine. I'm in the middle of writing the slides now, and it has been very challenging, mostly due to the nature of the material. How, exactly, does one teach "architecture" in four days? What does a lab exercise for a lecture entitled "service orientation" look like? Despite the challenges, I'm very pleased with the way the course is shaping up, and I hope to see a few of you in class once we start teaching it.

  4. MSDN2. Microsoft has brought me in to do some more work on the MSDN2 project, which has really matured since the Alpha release I helped write. I've got some really interesting stuff to talk about on this one, but I'm going to wait until a few things come together. Expect a series of posts in the coming months related to my work here.

 

The fact that I generally put time in on at least three of them most days makes for a lot of variety. I particularly like that I've got a mix of design and implementation going - nothing helps you figure out how to build something more than trying to build it (or something similar).

Wednesday, November 2, 2005

Unwanted Stack Trace in Web Services

At one of my clients, I've been helping them port their product to .NET. As part of the process, we've added a web service façade that exposes a good chunk of their functionality. It's been really interesting figuring out how to do that correctly. One of the things I recommended is that they put a catch (Exception) block in every [WebMethod].

 

The idea here is to control completely what goes out on the wire. If uncaught exceptions are allowed to propagate outside the WebMethod, the pipeline will call ToString() on the exception object and stick the result into the soap:fault. That means that we're projecting stuff like our call stack and the exception type onto the wire. This is neither useful nor desirable to the clients of the web service. Even if it was, the format the information is in would be a pain to parse.

 

So instead, we've done something like this:

 

[WebMethod] FooResult DoFoo(FooRequest request) {

   try {

      CheckSecurity();

      return ExecuteFoo(request);

  }

  catch (Exception e)

  {

     throw LogAndMapException(e);

  }

}

 

Where LogAndMapException looks something like this:

 

SoapException LogAndMapException(Exception e) {

  LogException(e);

 

  CustomException ce = e as CustomException;

 

  if (ce != null) {

    return CreateSoapException(ce.Code, ce.FriendlyMessage);

  }

  else {

    return CreateSoapException("generic error message");

  }

}

 

CustomException is an exception that we wrote that is thrown when application-specific error conditions occur. When we get this, we know we have information that might be useful to the client, for example, "You do not have permission to do what you tried to do." In this case, we create a SoapException that contains a code and a convenient human-readable string for that error. In all other cases, we throw a SoapException that just contains a generic error message. So we return as much information as we have, but not more than the client needs.

 

The key here is that when SoapException is thrown, the pipeline knows that you're trying to make the soap:fault look a particular way, and it'll map the properties of the SoapException into the fault message, rather than simply dumping the result of ToString() into it. Very handy. Except when it stops working.

 

Which is exactly what happened to us the other day. Since we have a UI that displays the human-readable part of the fault in a web page, it was pretty obvious to us that we were getting the stackdump style of message, rather than the nicely formatted one. To add to the mystery, we couldn't recreate the error on any of our dev machines - only on the web farm we deploy to as part of every build.

 

But wait! There's more! There are two nodes in the web farm (we'll call them A and B), and as I was playing around with the setup, I found that the problem only occurred when I pointed the web UI on A to the web service on A. If the web UI on A talked to the web service on B (and vice versa) the problem went away. Even weirder, if I set up tcpTrace as a simple call redirector so that web service calls went from machine A to machine C back to machine A, things also worked correctly. And I tried addressing the calls using the machine's full name, "localhost" and "127.0.0.1", but none of that made a difference. As long as the call didn't leave the machine, the error text was wrong.

 

After much screwing around trying to get remote debugging to work (with little success, as usual with that technology), I asked a few friends if they'd seen this before. Fortunately, the inestimable Henk had. (Henk is one of the smartest guys I know - hire him if you ever get the chance.) It turned out to simply be a matter of adding

 

<customErrors mode="On" />

 

to the web.config for the web service. Poof! Problem gone. I suppose it makes sense in retrospect that this tag would control pipeline mapping of unhandled exceptions for web services the same way it does for ASP.NET web forms, but frankly I found the resulting behavior highly unintuitive. I also can't explain why it only failed on our Windows 2003 web farm, and not on any of the other Windows 2003 or Windows XP machines we tried. But at least we're up and running again.

Tuesday, November 1, 2005

Sony CDs Install a Rootkit on Your Machine

This is one of those "horrible, but sadly unsurprising" stories. I think Bruce Schneier has it right when he suggests that companies should be made liable for security vulnerabilities that they introduce into your system.