Catastrophic Failure While Installing an Out-of-Browser Silverlight Application

While working on one of the demos for my upcoming Toronto Silverlight User Group presentation, I ran into a catastrophic failure. Actually, the starting point for the problem was that when I right-clicked on the Silverlight application and selected the installation option, nothing happened. No errors, no warnings, but also no results.

While trying to figure out the problem, I when to the more direct method of installation by programmatically calling Application.Current.Detach(). When this statement was hit, an exception was thrown with the following beautiful details.

System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Application_Detach(Application app)
   at System.Windows.Application.Detach()
   at LocalConnectionDemo.MainPage.Button_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

As you might guess, this is not particularly useful in the debugging process. After a fair bit of effort, I discovered the solution. I happen to be using a PNG file as the icon for the application. When the PNG file is added to the project, the Build Action is automatically set to Resource. When you change the Build Action to Content, the problem goes away.

Also, the same exception is thrown if the file used as the out-of-browser icon is not present at the indicated location.

I’m hoping that the exception becomes a little more useful as Silverlight 3 moves through the beta process.