Damian Mehers' Blog Android, VR and Wearables from Geneva, Switzerland.


MceFM released: Last.fm addin for Windows Media Center

Over the last few months I've been working on an addin to Windows Media Center which lets you listen to Last.fm based off of the artists in your music collection (you can also enter arbitrary artists names etc.).

I wanted it to work when the user wasn't running the MceFM application within Media Center, which meant creating a background application and a normal application.  That way you can listen to songs and watch your photo collection (for example).

Also, the Last.fm music streams don't include the tags normally included in mp3 files, which let you see the track name, artist, album name, etc.  So what I did was to dynamically add these tags to the stream, which means that Media Center will shown all that information correctly.

All in all, a lot of fun to develop.  Now I just need to see if anyone cares 🙂

More at http://www.mcefm.com/

Filed under: Uncategorized 4 Comments

Referencing external assemblies using MCML

MCML is Windows Media Center Markup Language.  You use it to define the GUI for your Windows Media Center applications.

I've been banging my head against the wall trying to get a reference to a .NET assembly to work in MCML.  The example in the documentation uses the syntax:


Where MSCorLib is the name of the assembly in the Global Assembly Cache.

This worked fine for me where the assembly contained the current Media Center Application:


However when I wanted to reference a different external assembly (that was also in the GAC) I was getting an error loading the MCML page, indicating that the assembly could not be loaded.

In the end I found out that I needed to use a strong assembly name:

xmlns:ext="assembly://ExternalAssembly, Version=, Culture=neutral,

I guess this is pretty obvious, but I'm also guessing that I won't be the only one to waste an hour or so on this.  The documentation doesn't give an example like this (just the weak named reference), although it does give strong named examples for resource references.

Filed under: Media Center 4 Comments

Handling background threads using NUnit and Rhino Mocks

I've just started using NUnit and Rhino Mocks, so this is not necessarily the best way to do things, but it works for me.

I have a class which has a method which kicks off a background thread.  This thread has an infinite loop -- for each loop it accepts a request and services the request.

I needed to test an instance of the class, for one specific incoming request.  There are two issues -- how to know when the object's background thread has finished servicing the request, and how to stop the background thread from looping back and accepting another request.

This is what I ended up doing:

public class ServerTest {

  public void SomeTest() {

    bool done = false;

    MockRepository mocks = new MockRepository();

    using(mocks.Record()) {

      // ... lots of 'Expects'

      // This is the final call which gets made in the background thread
      // to complete the handling of the request
      Expect.Call(someObject.LastMethod).Do((Expect.Action)delegate() {
        done = true;
    using(mocks.Playback()) {
      Server server = new Server();
      int count = 0;
      while(!done && count < 10) {

The key point is that in the test's action associated with the last method that gets invoked as part of your background thread's processing loop, you need to set a flag so that the test knows that the last method has executed, and also abort the current thread so that the background thread doesn't loop back, and consume another request.

Filed under: unit testing 2 Comments