Archive for May, 2007

Don’t Rename that MSI

The installer for the Apollo alpha release was made available, for Windows, as an MSI file. MSI files are the native format of the Windows Installer service. They’re essentially a single-file database containing the data required to install (and uninstall) an application.

It turns out that offering your installer download as an MSI file isn’t a terribly good idea. Unfortunately, we didn’t discover this until it was too late for the alpha release.

The first half of the problem arises because Windows Installer remembers the name of an MSI file when an application is installed, and it requires that subsequent installations of the same product use the same file name. (Windows Installer considers two products to be the “same” if the MSI file for both contain the same product GUID.)

The second half of the problem is your browser, which likely has a habit of renaming files that you download. For example, if you download the same file twice, it might helpfully append “(2)” to your second download to avoid overwriting the first.

Taken together, these two behaviors can make it surprisingly likely that you try to install the same product twice from MSI files with different names. If you trace the behavior of Windows Installer when attempting to open the second MSI file, you’ll find that it starts by correctly opening the second file, regardless of its name. Later, however, it will try to re-open that file using the original name.

This behavior doesn’t seem to be well documented, although I have found a reference in this Windows Installer Team Blog entry–look for Rule #14. I’m hard-pressed to argue that it’s not a bug, but maybe there’s a good reason for it that I just haven’t thought of yet.

Unfortunately, all of this can make Apollo’s installation experience look lousy. For example, see this blog about installing Apollo.

We’ve addressed all of this in the upcoming beta release by making the installer download for Windows an executable. It still contains an embedded MSI file and uses Windows Installer, but no one–not you, and not your browser–has the chance to give that MSI file the wrong name. Plus, it’s now got a nifty UI!

AssocQueryString and the Unknown Association

Most Apollo development for Windows is still being done on Windows XP, but we’re testing against at least some of the versions of Windows Vista.

On Windows XP, we’ve been using AssocQueryString to find the application associated with a particular file extension. (AssocQueryString is a utility function in the Shell that retrieves information about file types.) This broke on Vista, where the call was returning an answer even if no application was associated with the file extension.

The solution is to add ASSOCF_IGNOREUNKNOWN to the flags parameter. Otherwise, on Vista, if a file type is not registered it may return you information about the “Unknown” application instead of just fessing up and admitting nothing is registered. Again, this is a change from XP, which would admit the truth without this flag.

One more thing: Although ASSOCF_IGNOREUNKNOWN is defined in the Platform SDK documentation, it may not be defined in older versions of the Windows headers. Actual value: 0x400.

Java is the New C

Fifteen years ago if you had to whip up some industrial strength tools from scratch there’s a good chance you’d have chosen C as your language. These days, there’s a much better chance you’d choose Java.

You can see this effect in the tooling for Flash and Apollo. Flash and Apollo are themselves both written in C++ and ActionScript. To create an ActionScript 3 application, however, you can’t avoid going through Java. Here are four examples:

  1. You’ll be writing some ActionScript 3 code. That’s compiled to bytecode using a compiler written in–Java.
  2. You might be using Flex. The Flex compilers (mxmlc and compc) are also Java wrappers around the underlying ActionScript 3 compiler. There are even Ant tasks for Flex on Adobe Labs.
  3. If you use the Flex Builder IDE, you’ll note it’s a Java application written on the Eclipse platform. (You even have the option of installing it as a plugin to an existing Eclipse install–some Apollo engineers run it this way.)
  4. If you’re creating an Apollo application then you need to package it in an AIR file for delivery. Packaging is done via “adt”, a little tool written in–yes, Java.

No doubt there’s more than one reason for this, and the simple fact that Java is now often the teaching language for first-year computer science courses may account for a lot of it. But I also think it’s got a lot to do with the fact that Java is a surprisingly good systems programming language–which is exactly what C was designed to be.

Java may not have thrived in its intended markets, but it has found a niche in a lot of developer’s toolboxes.