Creating an MCML Application for Windows Vista Media Center
I recently posted instructions for creating a Media Center AddIn: Soup to Nuts
I am currently working on a new MCML (Media Center Markup Language) application for Media Center, so I thought I would post the same instructions with respect to MCML applications. Setup projects are a little different for MCML applications than they are for AddIns, and Media Center AddIns for Windows Vista can be created in Visual Studio 2005. Hooray!
This guide assumes a couple of things:
1. You are using Windows Vista
2. You have Visual Studio 2005 installed and working
3. You have installed the Windows Vista Media Center SDK
Media Center Markup Language is “an XML based declarative language that instructs the Windows Media Center renderer in how to display a user interface within the Windows Media Center Presentation Layer.” MCML is a welcome addition to the Media Center development platform because it provides developers with the control of .NET code, while allowing them to tap into the rich UI that Media Center users are used to. In this short guide we will create a very basic “Hello World” MCML application, install and register it with Media Center, and test it out.
Step 1: Create the MCML Application
- Open Visual Studio
- Select File | New | Project
- Select “Visual C#” | Windows Media Center | Windows Media Center Presentation Layer Application
- Type in a location, and a name for the project.
After you click OK, Visual Studio will create shell project for you with a couple of files. AddIn.cs is the class that will launch our MCML application. The AddIn class implements two interfaces: IAddInModule and IAddInEntryPoint. In the IAddInModule interface, the method “Launch” contains the code required to navigate Media Center to our MCML application. The Default.mcml file contains our MCML code that will display when the application is launched.
- In the Solution Explorer, rename the AddIn.cs file to something appropriate. In our case, MCMLHelloWorld_Start.cs.
- Inside MCMLHelloWorld_Start.cs, rename the class name, and set the namespace to something meaningful.
- The Default.mcml file contains the MCML code that will display when our application is launched. Let’s customize it a little bit.
- Now that we have our code in place, build and run the solution. Our application launches in McmlPad.
Step 2: Secure our Assembly
Media Center will only load assemblies that have been signed. So, we need to create a secure assembly.
The first step is to generate a keypair. If you already have a keypair that you use for other projects, you can just use that one. If not, it’s easy to create one with the “Strong Name Utility” that comes with Visual Studio.
- Open the Visual Studio Command Prompt by selecting it from the Start menu (in my case: Start | All Programs | Microsoft Visual Studio 2005 | Visual Studio Tools | Visual Studio 2005 Command Prompt)
- Change to your project folder (in my case c:\MediaCenter\MCMLHelloWorld\MCMLHelloWorld)
- Generate a public/private keypair by typing: sn -k MCMLHelloWorld.snk
The Strong Name Utility generates a filed called “MCMLHelloWorld.snk”, which contains our public/private keypair.
Next, we need to add our keypair to the project.
- In Visual Studio, open the AssemblyInfo.cs file that is in the Properties folder in the Solution Explorer.
- Change the AssemblyTitle to MCMLHelloWorld
- Change the AssemblyVersion to 1.0.0.1
- Change the AssemblyFileVersion to 1.0.0.1
- Right-click on the MCMLHelloWorld project in the Solution Explorer, and click Properties.
- On the Signing tab, make sure the “Sign the assembly” checkbox is checked.
- Under “Choose a strong name key file”, click “Browse…” and select the MCMLHelloWorld.snk file we just created.
- Now that the keypair is hooked up, build the project again.
Step 3: Build Setup Project
Now that we have an awesome MCML application that we want to run inside of Media Center, we need a Setup project to install the assembly in the Global Assembly Cache (GAC) and register it with Media Center.
Step 3A: Create a new setup project
- Right-click on your Solution in the Solution Explorer, and select Add | New Project
- Choose “Other Project Types” | “Setup and Deployment” | Setup Project
- Type in a location and a name for the project. 
When you click OK, Visual Studio will create a new setup project within your existing Solution.
Step 3B: Setup Project Settings
- In the Solution Explorer, select the Setup project.
- In the properties window, fill in the relevant project properties. In my case, I filled in Author, Manufacturer, ProductName, Title, and Version.
Step 3C: Add Files
- Click on the “File System Editor” toolbar button in the Solution Explorer to open the File System Editor
- Right-click “File System on Target Machine”, select “Add Special Folder” | “Global Assembly Cache Folder”
- Right-click on “Global Assembly Cache Folder”, select Add | Project Output
- Select Project: MCMLHelloWorld
- Select Primary Output
At this point, we have a setup project that installs our MCML assembly into the GAC. Visual Studio has detected that our setup project is dependent on the .NET Framework, so it has included a Launch Condition for us to make sure the Framework is installed.
Step 4: Add Media Center Launch Condition
One of the requirements of any good setup project is that it will prevent the user from installing on a non-supported operating system. We can accomplish this task by using a launch condition.
- In the Solution Explorer, click the “Launch Conditions Editor” toolbar button to open the Launch Conditions Editor.
- Right-click on the “Search Target Machine” folder and select “Add Registry Search”.
- Name the new item something meaningful, like “Vista Media Center Required”.
- In the properties window, set the Property, RegKey, Root, and Value properties. According to Aaron Stebner, this is the correct way to check for the existence of Media Center in a setup project.
- Right-click on the “Launch Conditions” folder, and select “Add Launch Condition”.
- Name the new item something meaningful, like “Vista Media Center Required”.
- In the properties window, set the Condition, and Message properties. An Ident of “3.0″ is for Media Center 2005.

Step 5: Register your Application with Media Center
Okay, before we can complete this step, we need to generate two guids for our application. Luckily, Visual Studio has a “Create GUID” tool that will do the job.
- Run GuidGen.exe from Program Files\Microsoft Visual Studio 8\Common7\Tools.
- Select the “Registry Format” in the tool, and copy your new guid to the clipboard using the Copy button.
Okay, I said we needed two guids, right? The SDK recommends that you use sequential GUIDs to register your application to make troubleshooting and locating them in the registry easier. We’ll call our two GUIDs the “Application GUID” and the “Entry Point GUID”.
- Application GUID: {C52CC2FE-6771-4e33-B384-BC445B482265}
- Entry Point GUID: {C52CC2FE-6771-4e33-B384-BC445B482266}
Now that we have our two GUIDs, we’re ready to create the registry keys we need…
- In the Solution Explorer, click the “Registry Editor” toolbar button to open the Registry Editor.
- Right-click on the “User/Machine Hive” folder in the Registry Editor and select “New Key”. Create a structure that looks like this:
Notice how we use our “Application GUID” under the “Applications” key, and our “Entry Point GUID” under the “Background” and “Entry Points” keys?
- On each of the GUID keys, change the “DeleteAtUninstall” property to true. This will unregister the application when it is uninstalled.
- Under the Applications\[GUID] folder, create two string values called “CompanyName” and “Title”.
Under the Categories\More Programs\[GUID] folder, create a string value called “AppId” and a DWORD value called “TimeStamp”. Put the Application GUID in the Value property of the AppId, and put your favorite timestamp in the Value property of the TimeStamp.
- Under the Entry Points\[GUID] folder, create string values called “AddIn”, “AppId”, “Description”, “Title”, and a DWORD value called “TimeStamp”.
This is where it gets a little tricky! If you have problems with running your MCML AddIn later, chances are that you made an error in THIS STEP.
The “AddIn” String value contains the information that Media Center needs to launch your AddIn. In my case, the string looks like this:
AnthonyPark.MediaCenter.MCML.MCMLHelloWorld_Start, MCMLHelloWorld, Version=1.0.0.1, Culture=neutral, PublicKeyToken=091b5809569f1055, processorArchitecture=MSIL
This is what is known as the “strong name” of your assembly. To construct this name, use the following formula:
FQCN + “, ” + SASN
Where:
- FQCN is the Fully Qualified Class Name of the class that implements IAddInEntryPoint (the class that Media Center is supposed to launch). In my case, it is AnthonyPark.MediaCenter.MCML.MCMLHelloWorld_Start (which is the namespace that my class is in, plus the class name).

- SASN is the Strong Assembly Name of your assembly. The easiest way that I have found to determine this is to install your assembly into the GAC using the GACUtil, and then use GACUtil -L to list your assembly:

- Put the Application GUID in the Value property of the AppId, and put your favorite timestamp in the Value property of the TimeStamp.
Step 6: Install and enjoy your MCML AddIn!



Dear Anthony,
thank you so much for such a great summary of the numerous tasks one has to do in order to register the application in Media Center.
I have, however, one question:
How do you actually construct the “AddIn†String which is in your case “AnthonyPark.MediaCenter.MCML.MCMLHelloWorld_Start, MCMLHelloWorld, Version=1.0.0.1, Culture=neutral, PublicKeyToken=163a3237539b1b96″?
What exactly are the two first attributes and how can I find them out?
Thanks a lot
Jan
Comment by Jan — April 5, 2007 @ 12:15 pm
Jan,
Yes, this has always been one of the more tricky parts of registering an AddIn for me. I have updated this blog post to contain the detail you are looking for. I also specifically address your question here:
Determining the Strong Name of a Media Center AddIn
Thanks,
Anthony
Comment by Anthony Park — April 5, 2007 @ 11:41 pm
Hi Anthony,
Thanks a lot for your post! It was very useful!
I was wondering if you knew how I could add an application icon to my app using this method.
Thanks in advance,
Erwin
Comment by Erwin — April 24, 2007 @ 8:02 am
Hi there, and thanks a bunch for the information, it saved me a lot of trouble, and I’m loving developing in this new environment. One thing I can’t seem to get working here (which does work when I use the registerMCEAPP method) is the image for the program. (referenced as ImageUrl in the registration.xml file.
Is there a way to do this using the setup project?
Cheers!
Comment by Adam — May 1, 2007 @ 10:51 pm
Awesome content!
This is the best article that I’ve ever seen on AddIn installation.
Thank you very much!
Comment by Kenichiro — May 25, 2007 @ 12:40 am
Adam,
Yes, the ImageURL can be done using this method for a setup project. You can create a registry entry in the “Entry Points\GUID” section of the registry called “ImageURL”. In the value for this registry entry, put something like: “[TARGETDIR]Images\MyApp.png”.
Just make sure that your setup project also puts the image on the machine in this location.
- Anthony
Comment by Anthony Park — May 29, 2007 @ 9:26 pm