My adventure creating a Media Center add-in, part 4

I know it has been a very long time since my previous post in this series, and I apologize for that.  I have been pretty busy getting Update Rollup 2 ready and then working through some of the issues seen by customers after we released it.  At any rate, I was sitting at the car dealership yesterday afternoon waiting for an oil change and tire rotation and decided to pick back up my effort to create a Media Center add-in.

The first thing I realized that I should do is check out the updated version of the Media Center SDK because we shipped an updated version at the same time that we released Update Rollup 2.  So I started out by visiting the download site for the SDK and tried to download and install it.  Since I already had the previous version of the SDK installed, I received a Windows Installer error dialog stating that another version of this product was already installed on the system.  So I went and dug through my Add/Remove Programs control panel and uninstalled the version of the SDK that I had installed, then went back to the download site and this time it installed fine.

I decided I wanted to try to look at the code and try to build one of the sample add-ins to get a feel for what this process looks like to the average add-in developer, and also because I wanted to see what the default add-in MSI would look like after using Visual Studio to build the MSI.  I decided to start with the screen saver sample (located in C:\Program Files\Microsoft\Microsoft Windows XP Media Center SDK\Sample AddIns\ScreenSaver if you install the SDK to the default location).  I found the ScreenSaver.sln file and double-clicked on it to launch it in Visual Studio.  I happened to have Visual Studio 2005 installed on my laptop, so I was prompted to convert the project files to the new format and stepped through the wizard to complete that task.

I glanced briefly through the code in Connect.cs and it made reasonable sense from a conceptual perspective.  So I decided to try to build the project by pressing Ctrl + Shift + B in the VS IDE.  When I did that, it ran for a while and then gave me some error messages about unresolved references.  As it turns out, there is a reference to the Microsoft.MediaCenter assembly in the References node in the VS Solution Explorer, and it had a yellow exclamation point next to it on my machine, which indicates that the file couldn not be found in the expected location on my system.  It was expecting to find Microsoft.MediaCenter installed to the GAC, but since my laptop is running Windows XP Pro and not Media Center, that file didn't exist anywhere on my system.

This presented an interesting dilemma to me - how do I get Microsoft.MediaCenter onto my development machine so that it will be recognized and allow me to successfully build this screen saver sample?  I had been planning to use a remote development strategy for creating an add-in (create it on a development machine, deploy it to a MCE machine to test it out, iterate as needed).  I definitely wasn't planning on using my Media Center machine as both the development machine and the test machine - it is configured on my TV in my living room, is set to 1600x900 resolution so the standard Windows desktop is barely readable without squinting and getting eye strain, and it doesn't even have Visual Studio installed anyways.  Plus, at the time I tried to build this project, I was sitting in a car dealership and didn't have access to a copy of Microsoft.MediaCenter.dll to work around this issue.  I dug through the MCE SDK documentation for a little while but couldn't find any mention of specific steps to take to build the sample add-ins correctly.  So I temporarily gave up on fixing the build until I got home.

Once I got home I found a copy of Microsoft.MediaCenter.dll on my Media Center machine, copied it to the GAC on my laptop by using gacutil.exe (a tool that is installed as part of the .NET Framework SDK), and tried again to build the ScreenSaver add-in.  This time it worked fine for me - the assembly reference no longer appeared with a yellow exclamation point and the project built correctly.

This is about all I had the energy to try last night, so I'm going to end this post here.  Next time, I'm planning on looking at the contents of the MSI that was created for the add-in and see if I can figure out a way to simplify the 26 step process in the SDK document entitled Creating a Windows Installer File for an Add-in.

[to be continued]


Comments (6)

  1. Steven Bone says:

    Hi Aaron – I have the same requirement as you, I like to build on my development PC and deploy to the media center. I have a few notes that may help others out.

    First, it is a bit easier to add the Microsoft.MediaCenter.dll to the GAC on the development machine by using the GAC’s shell extension. In explorer on the dev box (or by using Start->Run) type "%windir%assembly" to get an explorer window where you can drag and drop the assembly in the GAC. The assembly can be found on the Media Center PC in the "%windir%ehome" folder.

    Since I am working with VS2003, I use a post-build step to perform the following steps:

    1. Recompile the add-in using the .NET 1.0 csc compiler.

    2. Copy the build output plus the .mcl file to the media center machine.

    3. Use psexec.exe (from to unregister and register the add-in remotely. The command line for this is a bit tricky, so I’ll give it below (assumes the mcl copy is in the ehome directory). Since you first need to unregister the old one prior to registering the new one, the build step should contain the following line twice – the second instance should have the "/u" part removed:

    psexec.exe \MCE_COMP_NAME -w "windowsehome" "ehomeRegisterMCEApp.exe" "/u" "/allusers" "c:windowsehomeAPP_NAME.mcl"

    I haven’t gotten a chance to use VS 2005 much outside of the day job, so I don’t know if it is any easier to compile an assembly targeting a non-2.0 .NET Framework version.

    I also haven’t had the need to remotely debug an add-in, so I can’t offer advice for that – yet.

  2. Jeff Russo says:

    Don’t know if anyone will even see this anymore since I’m a bit late in reading it.

    Is there something special you need to do in order to get the Microsoft.MediaCenter.dll to show up in Visual Studio 2003’s Add Reference list? I’ve added it to the GAC using the gacutil. It’s definately there because I see it using either "gacutil /l" or Windows Explorer. But when I do an Add Reference it doesn’t show up. And choosing the Browse option is no help because as soon as I go into %windir%assembly it disables the Open button and won’t let me choose anything in there.

    In fact, I’ve noticed there are a number of assemblies in the GAC that aren’t in VS’s list.


  3. yad says:

    where do I find the dll file?  I don’t havea media center pc, just a win xp pro with and mc sdk’s.

    Please help.

  4. Hi Jeff – VS 2003 does not show assemblies that are installed in the GAC in the Add References list by default.  You will need to manually browse to a local copy of Microsoft.MediaCenter.dll or use a technique like the one I described at to get it to appear in the Add References dialog.  That last blog post refers to VS 2005, but the steps are pretty easily changed to work with VS 2003 instead.

    Hi Yad – You have to get a copy of Microsoft.MediaCenter.dll from a Media Center machine.  You will have to have a Media Center machine in order to install and test your add-in anyways, so I would not expect it to be a problem to find a copy of that DLL on the machine you are intending to test your application on.

  5. Brano says:

    Hi, is there a place where you can download the Microsoft.MediaCenter.dll for developers that dont have MCE? Seems really strange that Microsoft doesn’t ship this with the SDK as I don’t think anyone would ever program add-ins on a MCE machine.

  6. Hi Bruno – No there is not a place to download Microsoft.MediaCenter.dll.  I agree that developing applications on an MCE machine might not be too likely, but you can’t realistically ship an application that has never been tested, and you have to have an MCE machine to test an MCE application on.  If you have a machine to test on, you can get Microsoft.MediaCenter.dll from %windir%ehome on that machine to use on your development machine like I described in my blog post above…

Skip to main content