Detect .NET Framework Version Programmatically

If you need to determine what versions of the .NET Framework are available on a machine programmatically, you’d ideally use a C++ program (since it has no dependencies on .NET).  But if you can guarantee that .NET 2.0 will be available, there’s another option.  The source code (written by Scott Dorman) is ported from a C++ program.  I’m using the library for an application launcher that verifies the right version of the .NET Framework is available (among other prerequisites).


Calling MSTest from MSBuild or The Price of Not Buying TFS

When one of my colleagues left for a new opportunity, I inherited the continuous build setup he built for our project.  This has meant spending the past few weeks scrambling to get up to speed on CruiseControl.NET, MSTest and Subversion (among other things).  Because we don’t use TFS, creating a build server required us to install Visual Studio 2008 in order to run unit tests as part of the build, along with a number of other third-party tasks to make MSBuild work more like NAnt.  So the first time a build failed because of tests that had passed locally, I wasn’t looking forward to figuring out precisely which of these pieces triggered the problem.

After reimplementing unit tests a couple of different ways and still getting the same results (tests passing locally and failing on the build server), we eventually discovered that the problem was a bug in Visual Studio 2008 SP1.  Once we installed the hotfix, our unit tests passed on the build server without us having to change them.  This hasn’t been the last issue we’ve had with our “TFS-lite” build server.

Build timeouts have proven to be the latest hassle.  Instead of the tests passing locally and failing on the build server, they actually passed in both places.  But for whatever reason, the test task didn’t really complete and build timed out.  Increasing the build timeout didn’t address the issue either.  Yesterday, thanks to the Microsoft Build Sidekick editor, we narrowed the problem down to the MSTest task in our build file.  The task is the creation of Nati Dobkin, and it made writing the test build target easier (at least until we couldn’t get it to work consistently).  So far, I haven’t found (or written) an alternative task, but I did find a blog post that pointed the way to our current solution.

The solution:

<!– MSTest won’t work if the tests weren’t built in the Debug configuration –> <Target Name=“Test:MSTest” Condition=" ‘$(Configuration)’ == ‘Debug’"> <MakeDir Directories="$(TestResultsDir)" /> <MSBuild.ExtensionPack.FileSystem.Folder TaskAction=“RemoveContent” Path="$(TestResultsDir)" />

<Exec Command=""$(VS90COMNTOOLS)..IDEmstest.exe" /testcontainer:$(TestDir)<test assembly directory>bin$(Configuration)<test assembly>.dll /testcontainer:$(TestDir)<test assembly directory>bin$(Configuration)<test assembly>.dll /testcontainer:$(TestDir)<test assembly directory>bin$(Configuration)<test assembly>.dll /runconfig:localtestrun.testrunconfig" />

</Target>

TestDir and TestResultsDir are defined in a property group at the beginning of the MSBuild file.  VS90COMNTOOLS is an environment variable created during the install of Visual Studio 2008.  Configuration comes from the solution file.  Actual test assembly directories and names have been replaced  with <test assembly> and <test assembly directory>.  The only drawback to the solution so far is that we’ll have to update our MSBuild file if we add a new test assembly.


CruiseControl.NET, MSBuild and Multicore CPUs

When I was trying to debug a continuous build timeout at work recently, I came across this Scott Hanselman post about parallel builds and builds with multicore CPUs using MSBuild.  While adding /m to the buildArgs tag in my ccnet.config didn’t solve my timeout problem (putting the same unit tests into a different class did), pooling multiple MSBuild processes will certainly help as our builds get bigger.


The unexpected home of IsHexDigit

I was about to write a method that checked to see if a character was a hexadecimal value when it occurred to me that I should google for it.  I was going to name it IsHexDigit, and googling for that revealed this link.  I’m not sure why it’s in the System.Uri class, but it’s less code for me to write.


Implementing Mouse Hover in WPF

We’ve spent the past couple of weeks at work giving ourselves a crash course in Windows Presentation Foundation (WPF) and LINQ.  I’m working on a code example that will switch the datatemplate in a list item when the mouse hovers over it.  Unfortunately, WPF has no MouseHover event like Windows Forms does.  The usual googling didn’t cough up a ready-made answer.  Some hacking on one example did reveal a half-answer (not ideal, but at least a start).

First, I set the ToolTip property of the element I used to organize my data (in this case, a StackPanel).  Next, I added a ToolTipOpening event for the StackPanel.  Here’s the code for StackPanel_ToolTipOpening: private void StackPanel_ToolTipOpening(object sender, ToolTipEventArgs e) { e.Handled = true; ContentPresenter presenter = (ContentPresenter)(((Border)((StackPanel)e.Source).Parent).TemplatedParent); presenter.ContentTemplate = this.FindResource(“Template2”) as DataTemplate; }

The result: instead of a tooltip displaying when you hover over a listbox row, the standard datatemplate is replaced with an expanded one that displays more information.  This approach definitely has flaws.  Beyond being a hack, there’s no way to set how long you can hover before the templates switch.

Switching from an expanded datatemplate back to a standard one involved a bit less work.  I added a MouseLeave event to the expanded template.  Here’s the code for the event: private void StackPanel_MouseLeave(object sender, MouseEventArgs e) { ContentPresenter presenter = (ContentPresenter)(((Border)((StackPanel)e.Source).Parent).TemplatedParent); presenter.ContentTemplate = this.FindResource(“ScriptLine”) as DataTemplate; }

So once the mouse moves out of the listbox item with the expanded template, it switches back to the standard template.  Not an ideal solution, but it works.

This link started me down the path to finding a solution (for reference).


Gotta love this April Fool's Day gag from Google

Here’s the e-mail home page.

They’ve got a little announcement, technical specs, even a blog with annoying, cutesy music.


Free Software for Your New Computer

If you’ve bought a new PC or Windows laptop recently, it probably came “bundled” with a bunch of free software.  It is a near certainty that the bundled software you got is awful.  Most people I know who make their living from computers (the ones who use Windows instead of Mac OS X anyway) reformat the hard drive and install only what they need to avoid this junk.  Why this software is on your computer in the first place is another story.  This post is about where you can find free software you actually want on your computer.

The Google Pack (http://pack.google.com) is a great place to start adding software you actually need.  As of this writing, the pack contains 14 applications.  This includes applications like Adobe Acrobat Reader, Firefox, Picasa, Skype, and RealPlayer.  The biggest benefit of adding these applications to your new computer via Google Pack is the updater software.  You can configure it to automatically update applications when there are new versions.

Open Source Windows is another great source for free software.  Unlike the Google Pack offerings, none of the software you’ll find at Open Source Windows is offered by Google.  The types of software are broader in many ways as well.  They include instant messaging (IM) clients, RSS clients, video playback, sound recording, graphics/photo editing, even games.

So if you’ve got a new Windows machine you need to get running, get rid of the bundled software and pay those sites a visit.  It will only cost you a little time, and the quality of the software you’ll get in return makes it a worthwhile investment.


Recommended Listening: Derivative Dangers

If you want to know how long ago the seeds of the current financial crisis were sown, definitely listen to this episode of Fresh Air.  Terry Gross' interview of Frank Partnoy reveals not just how derivatives came to be unregulated, but who some of the players were in making it possible.  What may disturb you is how many of the people who made the current situation possible are playing key roles in trying to fix it.  Partnoy also authored F.I.A.S.C.O.: Blood in the Water on Wall Street.  He first wrote this book 12 years ago–before the collapse of the internet and telecom bubbles, before Enron, and the subprime mortgage meltdown that triggered our latest financial calamity.


Sometimes, I really love the web

I’m at the airport to pick up a couple of friends, just back from a week in Spain. Adam asked me last week if I could pick him and his fiancée up from the airport. Somehow, we didn’t exchange a flight number along with the airport and arrival time, so I had no easy way to see if anything changed. Thanks to the web, this was no problem.

A search for Dulles Airport brought up their website. A search for today’s arrivals from Spain revealed the flight number and scheduled arrival time (which turned out to be about 30 minutes later than Adam and I discussed last week). I put the flight number into flightstats.com, and not only did it give me both segments of the return flight, it updated the scheduled arrival time and provided a near real-time map of their flight as it approached.

So instead of showing up way too early, I got to Dulles just a few minutes before Adam called to let me know they’d landed. I was able to do all that (and write this post) with my iPhone 3G.


Alternative PDF Readers

According to an article I got from my boss, there is a flaw in Adobe Acrobat and Adobe Acrobat Readers that will allow hackers to take over your machine if you open a PDF file they send you.  The article only mentions Windows XP Service Pack 3 as a vulnerable OS, so it’s unclear whether Vista can be taken over this way as well.  Despite how serious this flaw is, a fix for it won’t be available until March 11.  Between now and then, you can either swear off the opening of PDFs entirely, or use an alternative PDF reader.

Those of us using Mac OS X (which understands the PDF format natively) need only make sure that Preview or Safari is the default PDF reader.


Las Vegas Sites and Attractions Photo Republished

One of my Las Vegas photos from a trip last year got picked up by a little online travel guide.  I originally posted it on Flickr (http://www.flickr.com/photos/scottlaw1/2916736404/).


Microsoft Gets It Wrong Again

According to this story, there’s no direct upgrade from Windows XP to Windows 7.  Given all the stories of people “downgrading” from Vista to XP, or not upgrading at all, it seemed obvious to me that Microsoft should make upgrading as smooth as possible.  Instead, XP users will have to backup data, re-install programs, and restore data.

Having used the Windows 7 beta on a spare laptop for awhile, I can say it’s a distinct improvement over Vista.  It’s just a shame that Microsoft has decided to make the upgrade experience more difficult for XP users.


The rest of the inauguration day story

The group of us that went down (my sister and I, plus two of our friends), secured our spot on The National Mall (close to 12th St NW and Madison Drive) before 9 AM.  They replayed some of the concert from Sunday while we stood or sat in the cold and waited.  What you may not have caught on TV was the big laugh we in the crowd made the first time an announcer told everyone to take their seats.  The other bit the broadcasts may not have shared was the booing from the crowd when George W. Bush was announced.

Getting out of DC took us longer than getting in.  The police and National Guard personnel were not very helpful at all.  We spent a lot of time stuck in a confused crowd at L’Enfant Plaza because they decided to change one of the entry points to exit only and didn’t tell anyone.  We saw uniformed National Guardsmen standing on top of escalators who did and said nothing.  I still haven’t figured out how all that law enforcement managed to not have a single bullhorn or PA system to direct crowds.  The four of us managed to find our way to the other L’Enfant Plaza entrance by worming our way through the crowd.  We might have seen it sooner, were it not for the fleet of tour buses parked on D Street.  They were tall enough to block the other entrance from view, even when I got a chance to stand on a low wall.  The commingling of people trying to get on tour buses and those of us trying to get into the Metro station (each of us going in different directions) contributed to a lot of gridlock.  There was at least one ambulance trying to get through part of the crowd we were stuck in, and they weren’t having much luck.

The Metrorail folks definitely get an A for today’s performance.  We didn’t wait more than a minute or two for a train the entire day.  They had enough cars that we didn’t have to let a single train pass in order for all four of us to get on.  Law enforcement in the L’Enfant Plaza area gets a D.  No crowd direction or control, no information or conflicting information.

Even with these minor hassles, I’m glad I went down there.  I had great company with me and a good time as a result.


So close, but so far away

We were making great time until we tried to get to L’Enfant Plaza. Even though we caught the first train that showed up, we spent over 20 minutes waiting in the tunnel because of another train.


On the train to downtown

We got on the train at Wheaton around 6:40am. There was a bit of a crowd on the platform, but we all got on the train with no problem. Once we got to Silver Spring Station, the train was packed (even with 8 cars).

By 7:06, we got to New York Avenue Station, the last time I could post before we went underground (and out of reach of the AT & T network).


Headed downtown

Of course it’s crazy for me to brave the cold and the crowds to see Obama’s inauguration on a jumbrotron far from the actual swearing-in–but I’m still going to do it.  He’s the first (and only) candidate I ever donated money to, so I’ve got to be at least somewhere in the vicinity.  I’ve got my route picked out, my wake-up time, cold-weather gear, pocket-friendly food, and enough memory cards for the camera to last all day.


Windows 7 Beta

Here are my brief impressions of it so far:

Installation

Requires that Vista be on the machine in order to upgrade to Windows 7 Beta.  Otherwise, you have to do a clean install.  Unfortunately, you have to attempt the illegal upgrade before you get the message that tells you this.  If Microsoft is trying to get people to let go of XP, letting them upgrade from XP directly to Windows 7 might be a good idea.  Otherwise, the install was pretty straightforward.

IE8

Disappointing.  It can’t render www.vmware.com correctly, so I couldn’t download VMware Player from the site.  I had a copy on a flash drive fortunately, and was able to install from there.  Firefox works just fine (so far).

Virtual Machine

It looks like there’s some sort of permissions thing preventing me from running them.  Adding the VMWare Player created an additional user on the machine.  When I tried to open the VM I already had, I got some odd sort of permissions error.

Drivers

Windows 7 Beta detected the biometric scanner on the Lenovo T61 I’m using and directed me to the most current driver.  Once I “enrolled” my fingers, it worked just fine.  It didn’t have any trouble at all with the SanDisk Cruzer Micro 2GB I’m using either.

Miscellaneous

The way Windows 7 handles active program icons in the start bar is rather clever, though it still retains the unfortunate multi-function button for logging out, switching users, shutting down, etc.

More impressions later as I play with the operating system more.  This version of the beta doesn’t expire until August 1, 2009.


World of Goo

For years I’ve been more of a console gamer (XBox 360) than a computer gamer, but World of Goo is trying very hard to change that.  I don’t normally like puzzle games, but World of Goo tricked me by hiding the puzzle/construction/physics inside a hilarious cartoon.  In addition to being fun, simple to control, and great-looking, it’s just $20.  So far, it’s available for the PC, Mac, and Wii.


In Search of Wireless Internet

Recently, I’ve gotten a couple of questions from family about where they can get wireless internet access.  People usually mean wi-fi when they ask this.  I tend to address this problem by location–either you want wireless internet when you’re at home, when you aren’t, or both.

The variety of places offering wi-fi is definitely increasing.  Beyond the usual suspects (Starbucks, Panera Bread, airports and hotels), it’s showing up in other places (e.g. downtown Silver Spring).  If you want to find the nearest wi-fi offerings in your zip code, visit http://hotspotr.com/wifi (thanks for the link Adrienne).  If there’s a charge for the wi-fi access, the service is mostly likely provided by one of the major cellphone service providers (Verizon, AT&T, T-Mobile).

For wireless access at home, you have your choice of any provider who offers broadband access.  For most of us, that provider will be a cable company like Comcast or a phone company like Verizon.  Either type of provider will be able to offer you a modem that provides wired internet access and wireless internet access.  They may try to charge extra for setting up more than one computer, but I recommend not paying.  You’ll be able to get a family member or friend to help you for free, or a local high school or college student for a lot less than Comcast or Verizon will charge.


Alternatives to Microsoft Office

My dad asked me yesterday if there were any free alternatives to Microsoft Office.  The one that came to mind right away was OpenOffice.org.  Writer, Calc, Impress, Draw and Base are the OpenOffice.org answers to Word, Excel, PowerPoint, Visio and Access.  The suite is free, open source, and available for Windows, Mac OS X, Linux, and Solaris.

If you’re ready to embrace cloud computing, even more options are available to you.  Google Docs offers word processing, spreadsheets, and presentation capabilities.  It does a nice job of handling Microsoft Word and Excel files.  Another alternative to the Microsoft Office suite comes from zoho.com.  It offers the same level of compatibility with Word, Excel, and PowerPoint of Google Docs or OpenOffice.org.  Zoho.com offers a wider variety of applications than Google Docs.  They use plug-ins to integrate with MS Office, Outlook, Internet Explorer, Firefox–even Facebook and smartphones (iPhone and Windows Mobile).