Partilhar via


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

  • Anonymous
    November 12, 2005
    The comment has been removed
  • Anonymous
    January 12, 2006
    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.

    Jeff
  • Anonymous
    March 07, 2006
    where do I find the dll file?  I don't havea media center pc, just a win xp pro with vs.net and mc sdk's.

    Please help.
  • Anonymous
    March 07, 2006
    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 http://blogs.msdn.com/astebner/archive/2005/11/28/497693.aspx 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.
  • Anonymous
    March 15, 2006
    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.
  • Anonymous
    March 15, 2006
    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...