Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

Possible cause of and workaround for XNA Game Studio Device Center crashes

Possible cause of and workaround for XNA Game Studio Device Center crashes

  • Comments 0

We have heard from some customers about problems while using the XNA Game Studio Device Center to add Xbox 360 devices in XNA Game Studio 2.0 and to add Xbox 360 devices and Zune devices in the XNA Game Studio 3.0 CTP (for example, the Connect bugs that have been logged here and here as well as several threads on the forums).  After having no luck reproducing this issue in-house for a long time, we have finally figured out the root cause and I wanted to post more details here in case anyone runs into this issue in the future.

Description of the issue

The specific problem we have seen is the following:

  1. Launch the XNA Game Studio Device Center
  2. Click the button named Add Device
  3. If you are using the XNA Game Studio 3.0 CTP, select the device type (Xbox 360 or Zune)
  4. For an Xbox 360:

    Enter a device name and click Next
    Enter a 25 character connection code

  5. For a Zune:

    Select the name of the Zune that is connected to the computer that you want to add

  6. Click Next to attempt to connect the device

In the problematic cases, after clicking Next, the Device Center will crash with an unhandled exception error dialog as soon as it starts trying to contact the device.  The exception details show that it is a NullReferenceException with the error message "Object reference not set to an instance of an object."

If this error appears, there is no way to add a new device using the Device Center.

How to work around this issue

If you see this type of crash in the XNA Game Studio Device Center, there are a few options we have found that should allow you to recover and successfully add devices in the Device Center UI:

  1. Download and install the repair tool that I have posted at http://astebner.sts.winisp.net/Tools/netfx20regtlib.zip.  Installing the MSI in this zip file will repair the incorrectly registered components on your system, and then you can safely uninstall the MSI.
  2. Installing the .NET Framework 1.1 will also fix the incorrectly registered components that are causing the problem behind the scenes in the cases we have investigated so far.  You do not need to do this if you have already installed the repair tool in step 1.
  3. Manually fix up one of the registry values on your system.  If you choose this option, you need to find the following value using regedit.exe and update the data - in the broken state, Version will be set to 1.a.  You need to change it to 2.0.
    [HKEY_CLASSES_ROOT\Interface\{805D7A98-D4AF-3F0F-967F-E5CF45312D2C}\TypeLib]
    Version = 1.a

    How to reproduce this issue

    The simplest case we have found that will reproduce this issue is the following:

    1. Install Windows Vista or Windows Server 2008
    2. Install the .NET Framework 1.1
    3. Uninstall the .NET Framework 1.1
    4. Install Visual Studio 2005 + 2005 SP1 or Visual Studio 2008
    5. Install XNA Game Studio 2.0 or XNA Game Studio 3.0 CTP

    The order of the above steps does not really matter - the key thing here that causes the problem is that the .NET Framework 1.1 has been installed and uninstalled on the system.

    More details about the root cause

    On Windows Vista and Windows Server 2008, installing and then uninstalling the .NET Framework 1.1 will cause all of the .NET Framework type libraries on your system to be left in an incorrectly registered state.  As an example, on a system in the broken state, the IDisposible interface will contain this type library version information:

    [HKEY_CLASSES_ROOT\Interface\{805D7A98-D4AF-3F0F-967F-E5CF45312D2C}\TypeLib]
    (default) = {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
    Version = 1.a

    However, if you look at the type library registration for mscorlib.tlb (which is the type library represented by the GUID listed above), you will see that it only has version 2.0 registered, not version 1.a:

    [HKEY_CLASSES_ROOT\TypeLib\{BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}]
    2.0

    Even more details about the root cause

    The root cause goes even deeper than what is listed above, and is particularly interesting to me because it is related to .NET Framework setup, which I used to work on in a previous role here at Microsoft.

    We have not seen this problem on versions of Windows prior to Windows Vista (such as Windows XP or Windows Server 2003).  When I went back to try to figure out why, I realized that this specific uninstall scenario was known to be a problem at the time that the .NET Framework 1.1 shipped.  As a result, the MSI-based installer for the .NET Framework 2.0 adds some artificial reference counts for .NET Framework 1.0 and 1.1 type libraries.  These reference counts prevent the .NET Framework 1.1 uninstall process from unregistering and uninstalling these type libraries, which makes this broken state unreachable on an OS that has the MSI-based version of the .NET Framework 2.0 installed or on an OS that does not have any version of the .NET Framework installed.

    Windows Vista and Windows Server 2008 include the .NET Framework 2.0 and 3.0 as OS components, and these OS components are not installed using the MSI-based installers.  The OS components do not add the same artificial reference counts as the MSI-based installer, so that leaves them vulnerable to these type library registration issues.

    So far, the only application that I have seen encounter any problems due to this broken state is the XNA Game Studio Device Center, but it is possible that other .NET Framework-based applications could be affected as well.  Using the type library repair tool (workaround #1 above) or re-installing the .NET Framework 1.1 (workaround #2 above) should fix all .NET Framework type library registration on a system.  However, fixing the single IDisposible registry value (workaround #3 above) will only resolve the crash in the XNA Game Studio Device Center - it will not fix the rest of the .NET Framework type library registration on an affected system.

    Fortunately, we have identified a code change that we can make in the XNA Game Studio Device Center to prevent it from crashing even in a scenario where the .NET Framework type libraries are incorrectly registered on a system.  This fix will be present in the final release of XNA Game Studio 3.0, so that means that the only susceptible versions should be XNA Game Studio 2.0 and the XNA Game Studio 3.0 CTP.

    Leave a Comment
    • Please add 8 and 4 and type the answer here:
    • Post