Those of you following me on Twitter might have noticed some complaints about the beta version of one of my new applications not working the way it should. The app implements a BackgroundAudioAgent to play an audio stream. When directly deploying the XAP to a device this works like a charm. For a last round of testing I submitted the app for private beta testing through the App Hub. To my big surprise the version downloaded through private beta instantly crashes when trying to start the backgroundagent. Apart from analyzing, signing, encrypting and repackaging the XAP nothing should be changed by the private beta process, so this should not be possible.
I don’t know if anybody experienced problems with apps crashing after going to the marketplace submissions process, but the first place to search for errors appears to be the detected capabilities. The Marketplace Test Kit performs the same analysis the marketplace does, so it’s easy to check. The engineering team is working on fixing the issues, but for the time being forcing detection by adding dummy elements is easiest workaround.
CauseWe investigated the problem together with the Microsoft Marketplace Dev Support team. We figured out the crash was related to the specified capabilities. To play background audio the agent relies on the ID_CAP_MEDIALIB capability. This was specified in our manifest-file, but during the submission process the required capabilities are analyzed and overwritten. Apparently the App Hub contains a bug causing the medialib capability to remain undetected in certain situations. When using the Marketplace Test Kit the same problem shows, it does NOT detect the medialib capability. When the application tries to execute any action related to this capability it simply throws an exception and crashes.
SolutionObviously this is a bug in the Marketplace Ingestion tool that Microsoft needs to fix. The support team states: “I can tell you that it’s a known problem at our side that Engineering Team is already investigating”. Fortunately there’s a pretty obvious and easy workaround to solve this problem. Just add a “dummy” page to your application. Add elements to this page the ensure detection of the missing capability. In my case we forced detection of the MediaLib capability by inserting a MediaElement and making sure at least the x:Name is specified( <MediaElement x:Name=”DUMMY” />). Now both the Marketplace Test Kit and the App Hub’s ingestion tool will detect the capability therefore solving the problem. Update: The support team also provided me with some other workarounds that are easier and cleaner, but still force detection of the missing MEDIALIB capability. If your app is referencing any of these libraries just add the one line of code to your app.
|If it’s referencing:||Then add:|
|Microsoft.Phone.dll||Microsoft.Devices.MediaHistory history = null;|
|Microsoft.Xna.Framework.dll||Microsoft.Xna.Framework.Media.MediaLibrary lib = null;|
|none of the above ones, so very likely it’s at least referencing System.Windows.dll||System.Windows.Controls.MediaElement me = null;|
Trackback from your site.