Windows 8 Event Viewer’s Immersive-Shell and Metro Style apps

By jay at March 16, 2012 20:41 Tags: , , , , , , , ,

TL;DR: This article talks about an app startup error that can happen with Metro Style apps in Windows 8, how the presence of an app.config file can prevent the app from starting and how the Windows event log viewer’s new Immersive-Shell section can help.

 

The Windows 8 Metro style Xaml/C# application development is an interesting experience.

Since .NET is merely on top of a WinRT and its native structure, you’re left in a bit of a darkness sometimes, when it comes to debugging problems that come from WinRT.

Silverlight and Windows Phone also have their fair share of blind issues of this kind, either by having the application that exits with no apparent reason (when it is in fact a StackOverflow) or because you’ve set two namespaces names with the same content.

You’ve basically left at guessing, particularly on Windows Phone and Silverlight for the desktop, and if you’re lucky enough you’re having a error code that specific enough so that you can narrow your solution to a dozen google can find for you. If you’re not, well you’ve got a E_ERROR. Fail, as they say.

Windows 8 is actually a bit better at that, because of the Event Viewer. There’s a lot of details that appear there, and it’s very informative.

But let’s dive into one specific problem I encountered recently.

 

Diagnosing the “Unable to active Windows Metro Style application” issue

I’ve been upgrading an application’s Reactive Extensions via NuGet to the latest and greatest 2.0-beta, and after doing that update, it turned out the application was not starting at all. The debugger was not very helpful either, showing me this cryptic message :

Unable to activate Windows Metro style application ‘xxxxxxxxx!App’.

Windows was unable to communicate with the target application. This usually indicates that the target application’s process aborted. "More information may be available in the Debug pane of the Output window.

There was not much more details in the output window, and worse, the managed code was not even called. The output window showed that no assembly from my app were even loaded.

In a normal startup, the App.xaml.cs type constructor should be at least called, but this time it was not. This meant that it could not be anything related to C# code, but only related to the configuration of the application.

 

Using the event viewer to troubleshoot metro apps

The event viewer is very well known in the IT administration side of computing, but less on the development side, which actually is a shame. This is the first place to dig into when the debugger can’t tell you what’s happening.

Microsoft’s been publishing a lot of information in these logs, and Metro style apps are no exceptions. There is a new section specifically for this type of apps that contains a lot of information to diagnose issues.

Here’s how to get there :

  • Open the start menu and type Event, select the Settings section
  • Open the View event logs item that shows up
  • Navigate to the Applications and Services Logs / Microsoft / Windows
  • Open the Immersive-Shell node

You’ll find there a lot of details about what’s happening in the new shell for Metro Style Apps.

For the specific case of my crashing app, I found out this message :

Activation of the Metro style application xxxxxxxxx!App for the Windows.Launch contract failed with error: Server execution failed

This helped a bit, but not that much. The Windows.Launch contract is actually the creation of the App.xaml.cs file, which I already knew was not called.

There’s actually a lot more information in that file, like live tiles notifications, but that probably a subject for another blog post.

 

Friends don’t let friends have an app.config file

After doing a lot of file removal, basically returning to a bare naked application, without any dependencies, the application was still not staring, until I removed the app.config file that had been added recently.

That file was added by the NuGet package update procedure, from 1.0 to 2.0 as a compatibility feature and it seems to be a very annoying file for WinRT… A bug, I assume.

So next time you find an app.config file in your Windows 8 Metro style app, remove it :)

 

Happy WinRT’ing !

blog comments powered by Disqus

About me

My name is Jerome Laban, I am a Software Architect, C# MVP and .NET enthustiast from Montréal, QC. You will find my blog on this site, where I'm adding my thoughts on current events, or the things I'm working on, such as the Remote Control for Windows Phone.