Tom Verhoeff

Eveoh, Student CS @ TU Delft, Microsoft Student Partner & more

Archive for the ‘ WP7 ’ Category

Last week I blogged about a problem I came across when beta testing a new WP7 application. My problem was related to the ID_CAP_MEDIALIB capability. Today I noticed somebody on twitter having similar issues.

PROBLEM! #wp7dev 's: When submitting an app that uses the video recorder <"ID_CAP_Microphone"> is removed http://t.co/PU3PSv62 #wpdev
@lancewmccarthy
Lance W. McCarthy

Fortunately there is a way to force detection of every capability. The key is knowing what reference to use to force the detection. In this post I will show how to implement a simple workaround to ensure detection. Please note that all of this is just temporary. Microsoft’s engineering teams are working on fixing these detection issues, so these tricks should not be required anymore in the future.

Detection process

First of all it is important to realize that the Ingestion Tool does not scan the actual C# and XAML (that’s not included in the XAP package anyway). The actual scanning happens on the Intermediate Language (IL) that is generated by the compiler. This is important to keep in mind when implementing this workaround.

Detection rules

Essentially both the Marketplace Test Kit and the App Hub itself use the same set of rules to determine what capabilities are required. Fortunately those rules are supplied with the Test Kit in understandable XML format. To find out what class you need to reference to force detection it is sufficient to check this list of rules. The rules.xml can be found in “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\Marketplace” For example here’s the part on the ID_CAP_MICROPHONE capability.

<Capability ID=”ID_CAP_MICROPHONE” Type=”Security”>
<Assembly Name=”Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553″>
<Namespace Name=”Microsoft.Xna.Framework.Audio”>
<Class Name=”Microphone” />
</Namespace>
</Assembly>

<Assembly Name=”Microsoft.Phone.Media.Extended, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e”>
<Namespace Name=”Microsoft.Phone”>
<Class Name=”Camera” />
<Class Name=”PhotoCamera” />
<Class Name=”VideoCamera” />
</Namespace>
</Assembly>
</Capability>

Forcing detection

The rules.xml file basically tells you what classes to reference to force the detection (I highlighted them). In any case you can just add a dummy file (either xaml or just cs) and make a reference to just one of these classes. In case of the Microphone @lancewmccarthy suggests this line:

Microphone microphone = Microphone.Default;

This is a Microphone-specific solution. Another option is to just add this line:

Microsoft.Xna.Framework.Audio.Microphone temp = null;

This is where you need to remember the code gets compiled before scanning. The compiler implements a lot of optimization which in this case would lead to discarding a variable that is never accessed. Adding another line that references the variable solves this. This can be pretty much anything, for example:

MessageBox.Show(temp.ToString());

If you would actually run this code it will always throw a NullReferenceException, but since this is a dummy file that will never happen. Although the code is unreachable the ingestion tool notices it. You can use the Marketplace Test Kit to verify this.

capabilities

Conclusion

By combining the information in the rules.xml with a simple dummy file you should be able to force detection of any capability. The other way around rules.xml can also help you identify why a certain capability gets detected. Do you come across any problems when using this method? Feel free to leave a comment or send me a tweet.

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.

Cause

We 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.

Solution

Obviously 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;

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.

Would you like this feature to be integrated into the WP7 emulator? Vote here!

An important aspect of every mobile application that uses the internet connection is the way it handles slow connections. As a developer you cannot predict if you are app will be used over high-speed UMTS or slow GPRS. In WP7 development there are some API’s available to determine the connection type, but you can never be sure about the exact speed. To ensure the best experience for your users testing some scenarios is very important. Unlike the Android emulator, the Windows Phone emulator does not provide any functionality to limit the network speed, but there are some alternatives that don’t require you to take your phone to the middle of an empty desert. In this post I will cover throttling of the network connection using NetLimiter.

netlimiter1 [More]

9b8ex

Two days ago the biggest Windows Phone 7 developer event to date in the Netherlands took place. With the official launch of WP7 in our country and the recent addition of Nokia phones to the line-up developer interest is rising. A total of about 300 attendees showed up for a full day of sessions including a basic introduction the dev platform and tools, more advanced topics like push notification and fast application switching and a session on app monetization. The sessions where presented by Maarten Struys, Fons Sonnemans and myself. A big thank you goes out to Microsoft’s Matthijs Hoekstra, the Dutch WP7dev evangelist, who organized the event at the High Tech Campus in Eindhoven.

[More]

Note for English readers: Yesterday I did a few sessions about Windows Phone/Smartphone app development at a Dutch event called Night of the Nerds focused on 14-18 year old secondary school students. This blogpost will introduce some resources to get them started. Because of the target audience this post is presented in Dutch.

Gisteravond tijdens Night of the Nerds heb ik drie presentaties gegeven over het ontwikkelen van smartphone applicaties. Night of the Nerds is een evenement gericht op middelbare scholieren van 14-18 jaar oud met interesse in techniek. Het evenement is open voor alles en iedereen die het leuk vindt om met techniek bezig te zijn. Tijdens een clinic van 45 minuten heb ik kort de wereld van smartphones en apps geintroduceerd en aansluitend een demonstratie gegeven van het bouwen van een simpele twitter applicatie. Veel bezoekers reageerden enthousiast en wilden graag thuis aan de slag met het bouwen van een eigen app. In deze blogpost vinden jullie alle benodigde informatie om de eerste stappen te maken als app-ontwikkelaar.

[More]

A while ago I blogged about one of the most useful features introduced with the new App Hub: private beta distribution. I have to admit, I use this one pretty often. Updating is not supported for beta’s (vote here if you would like it to be), so with every app I build my list of apps grows bigger and bigger. Unfortunately Microsoft appears to have missed a pretty obvious option, the actual deleting of beta’s that are finished anyway. I am able to end a beta, but it keeps showing up in the list.To keep thing manageable I decided to fire up my favourite tool Fiddler again. It helped me out with App Hub exceptions before and to my big surprise Fiddler again is the solution here. It does take some effort, but at least it keeps your App Hub account nice and tidy.

Notice the missing "Delete submissions" button

Notice the missing "Delete submissions" button

[More]

Back in July Todd Brix announced on the Windows Phone Developer blog that Microsoft pubCenter would be expanded 18 countries by the end of 2011. I haven’t seen any official announcement just yet (Update 27/09: Microsoft released an official statement today) but while checking pubCenter today I noticed it is now possible to select out of 17 countries when entering tax information. Switzerland is the only one missing compared to the list announced back in July (but hey, it’s still 2011). When exploring some more I noticed that signup now lists 12 countries and payment requests can be made for the same 12 countries. The expansion doesn’t appear to be completed, but still it’s very good and important news for WP7devs living outside the US.

So what are the improvements that I noticed:

  • Tax information can be entered for 17 countries
  • Payment can be requested for 12 countries
  • PubCenter accounts can be created based in 12 countries
What are the drawbacks still in place:
  • Still only US impressions are counted
  • Still a valid US Tax ID is needed, just as with revenue from your apps
I guess all information will be disclosed in an official statement by Microsoft soon, since everything is already live on pubCenter right now.

Yesterday I published a blog about private beta testing, one of the great new App Hub features. Although the feature itself is great part of the process can be a little frustrating. One of the things that frustrated me was the requirement to submit the full load of artwork. In the first stages of testing I usually don’t have all the artwork/screenshots finished yet, which in the end forced me to create some dummy artwork. The same holds when you don’t want your artwork to be available yet before the official launch of your application.

To save some frustration in the future I will just share my dummy artwork. I did not try to give it any kind of design so it’s ugly, but at least it will be accepted by the App Hub. Feel free to use it in your beta tests. Here’s a zip containing all the files.

Happy beta testing!

 

A while ago Microsoft introduced a big improvement to the App Hub. Recently I gave one of the new features, private beta testing, a spin. The process is actually easier than I thought it would be. There are a few things to keep in mind though. In this post I will share a quick walkthrough for distributing your app through private beta-testing. Please pay attention to the remarks. Dutch readers might recognize the info in the post, I recently started as an editor at Dutch WP7 community and newswebsite WP7.nl where I published a similar article in Dutch

[More]

With the launch of the new App Hub Microsoft also opened up 19 new consumer markets for application submission. Developers running the Mango beta can already access the new marketplace and thus can leave reviews for applications. Therefore I updated the Review Reader with support for all new marketplaces. If you haven’t done so please make sure your applications are submitted to the new marketplaces, even if your app was set for worldwide distribution it requires manual action (see my blogpost on worldwide distribution).

It’s also worthwile to note a few changes to the new App Hub that impact checking your reviews. Within the App Hub it is now possible to view reviews and average for one marketplace at a time. This is an improvement, but MS isn’t quite there yet when they want to provide easy and efficient access to reviews.  Compared to the App Hub my review reader still offers this extra functionality:

- Overview of all marketplaces

- No-nonsense interface

Excel/CSV export

A try at contacting the reviewers

- Average ratings since last update

I still hope Microsoft will improve this experience in a future update, in the meantime my tool will stay available for all WP7 devs out there. Please let me know if you have any feedback or feature suggestions. You can find me on Twitter.