Wednesday, January 03, 2007

Someone asked me the other day if you could reflect on other people's assemblies using the CLR.  My answer was, "ABSOLUTELY!!!!!"

As it turns out, they were having some problems achieving this, and they were wondering if there was some kind of security mechanism in place that was preventing reflection on 3rd party assemblies.  Here's the basic scenario.  They had a 3rd party library with a type that defined several "constants" using fields.  They needed to be able to specify a named constant via a string and return the value for the constant.  Security and performance arguments aside (they had already been considered), they simply wanted to lookup the field by name via reflection and get its value.  This can be accomplished via just a few fairly reasonable lines of code using one of the GetField family of methods on System.Type and then getting the value.  I'll leave this as an exercise for the reader so they can have the fun of wresting with the silly BindingFlags enum.

After some discussion, I learned that the trouble actually revolved around getting the Type object in the first place.  They were using Type.GetType to load the type with a namespace-qualified name as the string argument.  It was returning null (Nothing in VB).  They were validating that the string was correct using Intellisense, and concluding that since Intellisense could see the type, that Type.GetType should also "see" it (which seems like a perfectly reasonable assumption).

Type.GetType() takes a string argument specifying the type to retrieve.  When specifying types in strings, you can usually use a namespace qualified name ("[namespace.]type"), or an assembly-qualified name ("[namespace.]type, assemblyName").  If you don't provide the assembly name, the API looks through the assemblies already loaded in the AppDomain for a type that matches the name.  If an assembly name is specified, a bind occurs to the assembly and it is loaded if necessary.

In this case, there was a reference to the assembly containing the type, so Intellisense was picking it up and providing completion. The trouble was that, at runtime, the assembly had not yet been loaded into the AppDomain, so the type was unavailable.

So, the options were (in order of appropriateness in my opinion):

  • Use an early-bound type - Since the type was known at compile-time, use typeof() (GetType() in VB).  This will create a compile-time, assembly-qualified type reference in the IL rather than a runtime parsing/bind/load of the type string.
  • Use an assembly-qualified type string - Adding the assembly name to the type string will let the CLR know what assembly to look in (and load if necessary).  There are some subtle versioning issues with this approach, especially for strongly-named assemblies.
  • Make sure the assembly is loaded prior to calling Type.GetType() - Making an early-bound call to something else in the assembly first will get it loaded into the AppDomain.  This seems like a fragile solution and I would not recommend it, although it will technically work.

The real issue here is the number of samples (especially in VB) provided by MS that use Type.GetType() with a non-qualified name (ex. "System.String").

posted on Wednesday, January 03, 2007 9:09:25 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Tuesday, January 02, 2007

This year, we gave the gift that keeps on giving... the stomach flu. But, before I get to that, let me back up a bit...

If you recall, we got our power restored after over a week of outage with just a little more than 12 hours to prepare for our holiday travels.  However, we managed to get everything together and arrive at the airport the suggested 2 hours before the flight.  Out trip went through Phoenix instead of Denver, so I figured we'd be in the clear weather-wise since nothing ever happens in Phoenix.

Wouldn't you know it, we got to the airport to discover our flight had been delayed due to fog in Phoenix.  After a bout with a touchy airline representative (which I may eventually devote an entire entry to), we decided to go ahead to Phoenix since everything was delayed coming and going in hopes that our connecting flight would be delayed as well.

4.5 hours after our flight was to leave originally, we boarded the plane with still a slight chance of catching our connection.  After we landed in Phoenix, we discovered we'd missed the connection by a mere 19 minutes.  With no flights available to El Paso until Christmas, we really had only one acceptable option... rent a car and drive.  So, at about 9pm, we hopped in a car and drove the 6.5 hours from Phoenix to El Paso to Becky's parents house.  All in all, I felt a great sense of accomplishment in having executed such an old-school road trip with a 1-year-old.

Christmas with the Pattersons was great.  I got something I have wanted most of my life... a radio-controlled helicopter.  Thanks everyone.  The only issue was that things in our room were much colder than we were used to, which resulted in Jenna waking up every 30 minutes after midnight due to being cold, and she got all sniffly and such.

We went to Cattleman's (a world-famous steakhouse) for dinner Christmas eve, and I had a huge t-bone.  It was delicious.  Becky had been feeling ill earlier in the day, but we attributed it to lack of sleep.  After dinner, she took a turn for the worse.  I started feeling bad, but attributed it to eating too much.  Becky went to the doctor while I put Jenna to sleep.  By the time Becky got back, I was full on sick, but it was too late to see the doctor.  It was probably the worst night of my life.  Becky's dad helped us tremendously by tending to Jenna, who had also caught the bug.

The next morning, after an unpleasant episode in which I thought I was literally dying, I went to the doctor too.  We were scheduled to fly to Austin and drive to Belton this day, and were contemplating delaying the trip.  We ultimately decided that the pros of keeping our original schedule outweighed the benefits of staying longer.  So, somehow, we got on a plane to Austin and then drove the hour from Austin to Belton.  Unfortunately, the wake of our illness still spread to virtually all of Becky's family.  Some of them got sick on their flights home.

In order to avoid getting sick when we arrived in Belton, my parents just waved to us as we went to the apartment behind the house where they work.  They had gone to alot of trouble to quarantine us away, which was great because we had alot of room for Jenna and we had complete control over the temperature.  For the next few days, we followed a protocol of constant hand washing and such to prevent the spread of the plague.  We even avoided seeing my brother's family completely to avoid any complications for their new son who was less than a few weeks old.  This seemed to be working until my Dad got sick, followed by my mother that night.  My aunt also got sick on her flight home.  We ended up canceling several rendezvous we had planned with friends in the area.  In the end, we finally had a very short visit with my brother's family on his back porch.

Even though we had to be up at the crack of dawn on the 1st to get to the airport, we thankfully had an uneventful and undelayed flight home, and we just sat on our couch in disbelief of the events that had transpired during the previous few weeks.  Now, we just have to shift Jenna 2 hours back to Pacific time.

So, to everyone we had hoped to visit while we were in Texas, we're sorry things had to go down like that.

posted on Tuesday, January 02, 2007 4:26:53 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Friday, December 22, 2006

So, 1 week +12 hours give or take, and power has returned.  Unfortunately, cable is still out, so no XBox for me tonight.  We leave for Texas tomorrow morning.  Let the fun begin!

posted on Friday, December 22, 2006 1:14:18 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, December 21, 2006

In all the craziness brought about by the lack of power (still none, by the way), I have neglected to relay an important announcement. My brother and his wife had their baby! Landon Ross Miller was born Friday the 15th of December at 11:09 PM.  Everyone is doing well, and we can't wait to meet him next week.

Congratulations, Bro!

posted on Thursday, December 21, 2006 2:33:24 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Wednesday, December 20, 2006

So, we still don't have power, but things are looking up.  Let me give you the rough timetable so far.

  • Thursday, Dec 14th ~8pm: Wind starts picking up. Lights begin to dip occasionally.
  • ~10:30: Power goes out.  Ticked because I was in the middle of a Halo match.
  • ~11:30: By this time, the wind is really blowing.  The sound of branches breaking off can be heard occasionally throughout the surrounding woods.
  • Friday, Dec 15th ~12:30am: The wind is blowing like crazy.  The gusts are bending the trees to an alarming degree.  We decide we should move downstairs in case one decides to fall.  This wakes Jenna up and she decides we are playing some kind of game.  She spends the next several hours honking our noses.
  • ~2:00am:  I am VERY concerned about falling trees.  With each gust, the sounds of breaking trees can be heard.
  • ~4:00am:  Jenna is finally asleep.  The wind seems to have subsided.  We go back upstairs to be comfortable.
  • ~morning: Damage is surveryed.  Nothing major.  Check around the neighborhood.  Nothing terrible.  Patiently wait for power to be restored.
  • ~noon: It's getting cold.  I look for some firewood.  All I find is soaked through.
  • ~3pm: still no warmth.  We decide to bail.  We call the Flints and head to Bellingham.
  • ~7pm: We arrive in Bellingham, warm up, and stay the night.
  • Saturday, Dec 16th: Head back to our house to check on the cats.  The daylight reveals the devestation of the infrastructure.  Trees are down everywhere.  Powerlines are a tangled mess.  The power's going to take a while.  We make sure the cats are OK, and head back to Bellingham.
  • Sunday, Dec 17th: Attend Jeff's church and locate a generator that meets our criteria.  Big enough to run the furnace, small enough to fit in the trunk.  Head back to the house and fire it up.  Becky took Jenna to a friend's house while the house warmed up.
  • 8pm: the house reaches 60 degrees, our criteria for staying the night, so Becky brings Jenna back and we put her to bed.
  • 10pm: the house reaches normal temperature.
  • Monday, Dec 18th 12:30am: The furnace stops working and the house begins cooling fast (the structure itself has not yet heated up to normal)
  • 1:00am: We head to Becky's friends house and spend the rest of the night.
  • Daytime: Jenna and Becky hang out at her friends house, and I go into work to see about arranging furnace repairs and do other errands in addition to keeping work from falling too far behind.
  • Evening: return to Becky's friends house, and have a nice evening playing with Jenna and xbox. Becky and friend go check on cats, which are freaking out, but otherwise doing fine.
  • Tuesday, Dec 19th: Some work.  The furnace guys show up and confirm my diagnosis of a faulty flame sensor.  Furnace working again.
  • Evening: Head to another one of Becky's friends for some nice dinner.
  • 8:00pm: I get a call from my realtor, who just got power and offers his huge generator.
  • ~9:30pm: Big generator hooked up and running.  Now we can run some lights and other stuff. Additionally, it runs all night on a tank of gas, rather than having to fill every 5 hours.  Also discover cable service is out.  No xbox.
  • Wednesday, Dec 20th morning: wake up from a very pleasant and successful night. Fill tank on the generator and go out to get more gas.  Then head into work.
  • 1pm: Becky and Jenna join me at work for some lunch.

In somewhat unrelated news, I saw what I believe to be a couple of river otters swimming in the creek yesterday evening.  The reason I think they were otters was they looked like otters, and the tracks I found in the snow look like otter tracks. I'll have to keep my eyes open for them and maybe get some pictures.

posted on Wednesday, December 20, 2006 2:46:57 PM (Pacific Standard Time, UTC-08:00)  #    Comments [5]
 Monday, December 18, 2006

I've gotten lots of inquiries lately where, for now, the answer is simply, "we're alive".  If you weren't aware, the Seattle area was pounded last Thursday by an incredibly fierce windstorm.  Over two thirds of the houses in the area lost power, which equates to over a million customers (houses/businesses). We live in one of the areas hardest hit by the storm.

Luckily, we, our cats, our home, our cars, and everything else all escaped unharmed.  However, we have been without electricity since Thursday night.  We decided the best course of action with a one-year-old was to get the heck out of there.  We stayed with the Flints Friday and Saturday night.  After a brief period of warmth on Sunday brought by a generator, we are now staying at a friends house in nearby Kirkland who regained power on Sunday.

I'll update more when I have more time.  For now, I'm working on getting the furnace fixed.  Either running it continuously for about 8 hours damaged part of the ignition system, or running it from a generator screwed something up.

Hopefully, everything will be cleared up in time for us to make a Saturday flight to Texas for the holidays, but they're saying it may be Friday or Saturday before our power gets turned back on.

posted on Monday, December 18, 2006 3:39:53 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, December 11, 2006

Today is Jason Owens's birthday.  Jason is a buddy of mine from way back.  I believe we met before preschool sometime, but I honestly can't remember.  We shared all the years of school together, even through college.  I remember turning on the water hose in his backyard so we could try to turn it into Degoba (sp?) so we could play Star Wars properly.

Since college, we haven't been able to get together much.  We're supposed to get together over Christmas though, which I'm looking forward to.

Every year, it was a tradition for some of our closest friends to get together at Jason's house for his birthday.  We'd spend the night playing slaughter-ball, football 500, and topping it off with a viewing of "¡Three Amigos!".

Happy Birthday, man.  I was going to scan an old picture for this entry, but I haven't found the box with the old pictures in it yet, since moving.

posted on Monday, December 11, 2006 8:24:34 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Saturday, December 02, 2006

Today, my little girl turns 1 year old!  I've been teaching her to answer how old she is by pointing a finger in the air and saying "one!".  It's been an incredible year.  Jenna's been such a trooper over the past few months as we've moved across the country.

We got her a new forward-facing car seat, since she now meets that criteria.  We also got a cute little chair she can sit in that is electronic and does all kinds of fun-ness.  We made her a little cake and let her go at it.  She wasn't as destructive as I thought she might be, but it was fun.  Then we had a bubble bath, and I made lots of bubble hats for her that were hilarious.

For those wondering...  She walks excellently now, and chases the cats all over the house.  She's got 7 or 8 teeth.  I've lost track of all the things she can say. She'll repeat (or at least try) almost any word you ask her to say. She can ask for foods that she likes (apple, banana, broccoli, cheese).  She even says, "cheese, please".  She identifies the basic animals (kitty (sometimes referred to as "meow-meow"), puppy, bear, bird, bee, mouse, etc.  but horse is the cutest-sounding), and (when coaxed) she can tell you what sounds some of them make.  She can identify basic body parts.  She loves pointing at noses, even those of stuffed animals, but her favorite is "toes".  I went in one morning to wake her up, only to find her rolling around in her crib.  She looked at me with a big grin, grabbed her toes and said, "toes".  She dances to music, and plays peekabo (even with herself in the mirror). She will do things that you ask her to, like "go find a ball", "go find the kitties", "put on a hat", or "make Farmer Tad play the banjo".  She loves to hide, especially when you're trying to dress her.  She's cuckoo for bathtime.  I'm so proud of how well she's doing.  But,we wish she'd sleep better.  She's doing better than a month ago, but still gets up at least once during the night usually.

I've got lots of pictures and video from the day that will trickle in as I have time, but here's a cameraphone shot of her in her new car seat.

posted on Saturday, December 02, 2006 10:15:58 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Wednesday, November 29, 2006

Lots of snow - Blue skyMaking snow ice cream!It hasn't snowed any more. In fact, yesterday was a clear, beautiful day.  You can check out the photos I uploaded yesterday for all the snowy goodness, as well as some overdue photos since Halloween.  But, the temperature hasn't gone up, so all the snow is still here.  I even went outside, got some snow, and made some snow ice cream, which I haven't had in ages. (It doesn't snow enough in Central Texas to get clean snow)

the road this morning My smart card reader is broken, so I don't have remote access, which makes it hard to work from home.  I decided to go into work today to try to get another one.  It's supposed to snow more tonight, so I wanted to be ready, and not feel like I need to go in.  The way into work was interesting.  There were still lots of cars in ditches or stuck going up hills, etc.  But, I can't find a card reader, so I'll probably head home soon.  I don't want to risk getting stuck on the way home.  So, I'm going to queue up some work for the rest of the day and head out.

posted on Wednesday, November 29, 2006 10:12:20 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]