Sunday, January 16, 2011

Visual Studio & Expression Blend crashes when opening Silverlight XAML

NTSTATUS: STATUS_FATAL_ERROR

This happened to me recently, and it was a nightmare to repair. I will document my experience as many people faced the same problems, and different solutions worked for different people.

I was using Visual Studio 2010 and Expression Blend 4, developing Silverlight 4.

I will put the important points of this post here instead of at the end to save you, the reader, time.

Determined Root Cause of Damage: Updated Silverlight runtime to the latest version.

Caveat: Do NOT install a newer version of Silverlight unless you have the matching developer runtime (if you are developing Silverlight apps). I would also point out that it was IMPOSSIBLE to find the matching Silverlight developer runtime for the latest version of Silverlight. I am extremely infuriated and disappointed.

1. The Problem As It Happened

Suddenly, whenever I opened a Silverlight XAML file, Visual Studio crashed. It does not happen to WPF XAML files. I don’t think I tried Blend at this point as I was trying to get some work done, and was trying to fix my VS.

Steps taken:

  1. Uninstalled Silverlight 4 Toolkit
  2. Reinstalled Silverlight 4 SDK. Did not do an uninstall as the SDK documentation said it was safe to do (unless I read it wrong)

Results:

  • VS still crashes when opening Silverlight XAML
  • Blend 4 crashes when opening Silverlight XAML. It cannot be confirmed if the steps taken caused this, or it was already damaged

2. Reinstallation

The next desperate step was to reinstall my dev tools. This did NOT fix the problem. But I will detail it for the record.

Steps taken:

  1. Uninstalled Silverlight 4 Toolkit
  2. Uninstalled Silverlight 4 SDK
  3. Uninstalled Silverlight 3 Toolkit
  4. Uninstalled Silverlight 3 SDK
  5. Uninstalled Silverlight Runtime
  6. Uninstalled Visual Studio 2010
  7. Uninstalled Visual Studio 2008
  8. Uninstalled Blend 4
  9. Uninstalled Blend 3
  10. Install Visual Studio 2010
  11. Install Blend 4
  12. Install Silverlight 4 SDK
  13. Install Silverlight 4 Toolkit

Results:

  • VS still crashes when opening Silverlight XAML
  • Blend 4 still crashes when opening Silverlight XAML

At this point, it is safe to say that the system is irreparably damaged. I read that some folks had to reinstall their entire system. So not wanting to waste any more time, I restored my last good system image.

3. System Restore & Update

Having restored my system to the last good image, I attempted to update it. I verified that VS and Blend are working properly with Silverlight 4 XAML files. However, when I ran my Silverlight 4 app, it insisted I install a newer version of the Silverlight runtime and just refused to run. I could not understand this as I had just restored my system to an older state which actually is using an older version of Silverlight (4.0.50524.0). I figure this out later. I had no choice at the time, so…

Update Steps:

  1. Update Silverlight runtime to version 4.0.51204.0 (Current version is 4.0.50524.0)

Results:

  • VS cannot debug Silverlight 4 app because the developer runtime does not match the current Silverlight version

So this is a big problem. To fix this, I tried the following:

  1. Uninstall Silverlight runtime
  2. Download and install the latest Silverlight 4 developer runtime that I could find

Result:

  • VS can now debug Silverlight 4 app again
  • However, VS now crashes when opening Silverlight XAML
  • Blend 4 also now crashes when opening Silverlight XAML

So, it looks like this was how my system got damaged in the first place. I vaguely recall installing the latest version of Silverlight when prompted some weeks or months ago, and I had not worked on a Silverlight app until now.

I restored the system AGAIN, and did NOT install the latest version of Silverlight. However, there was still that nagging problem of my app insisting I install the latest version of Silverlight! I finally figure it out:

Silverlight App Project

  • The param “minRuntimeVersion” of the Silverlight object in the host webpage is what causes the popup to install a newer version of Silverlight if the value is above the current version installed. So just make sure that this is no greater than your current version of Silverlight.

<param name="minRuntimeVersion" value="4.0.50401.0" />

  • I believe that I had created the said Silverlight app project after installing the newer version of the Silverlight runtime, and this is what caused the popup dialog to insist on the newer version of Silverlight even after I restored my system. This would make sense as my project was not affected by the system restore.

Conclusion

Ultimately, I was not able to repair the damage. I could only restore my system back to a point where my development system was all good. The only thing I could really do was to make sure that I do not take any of the steps that would cause that kind of damage. And these steps, are those I laid out which I figured out through trial and error. I could have figured it out faster, but unfortunately, installs, uninstalls and system restores take a very, very long time. In all, it was about 18 hours wasted because nothing new was achieved… It was all just to get back to square one.


No comments:

Post a Comment