Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio
All postings are provided AS IS
with no warranties, and confer no rights. Additionally, views expressed
herein are my own and not those of my employer, Microsoft.
I have run into an issue a few times recently while helping folks create installers for their Windows Vista Media Center applications that are based on the project templates that ship in the Windows Vista Media Center SDK. As a result, even though this is covered in the SDK documentation and on the Media Center Sandbox blog, I wanted to specifically describe this scenario, the underlying design of Media Center that introduces this issue and how to fix it in your application.
Description of the problem
When creating a new Windows Media Center Presentation Layer application using the project template included in the Windows Vista Media Center SDK, an XML file is generated that can be used with RegisterMceApp.exe to register the application with Media Center. However, this XML file does not contain a public key token value (because it is not possible to know ahead of time what the public key token will be for each developer/company/etc). If you do not add a strong name key file to your Media Center application assembly and also add the PublicKeyToken value to the XML file, you will be able to register the application and it will appear in the Media Center UI after registering it, but it will fail to launch correctly.
Why does this happen?
Media Center currently only supports loading application assemblies from the global assembly cache (GAC) or from the %windir%\ehome directory. As a best practice, application developers should install their assemblies to the GAC on users' systems and not fill up the %windir%\ehome directory with files that are not a part of Media Center itself.
If you are creating a Media Center application that consists of a code-based assembly, and that assembly is installed to the GAC (which it should be if you follow the best practice I listed above), you must register the application using the RegisterApplication API or the RegisterMceApp.exe utility. When the assembly is located in the GAC, you must specify the full strong name identity for the assembly or else Media Center will not be able to locate the assembly to load it correctly. The strong name identity for .NET Framework 2.0 assemblies that can be loaded by Windows Vista Media Center consists of the assembly name, the assembly version, the culture, and the public key token (and the processor architecture if you need to create and ship non-MSIL assemblies for some reason).
How to fix this issue
In order to fix this issue, you need to do all of the following:
Charlie wrote up excellent instructions for developing Windows Vista Media Center applications that include steps to do all three of the above things, and they can be found in the Media Center application step-by-step instructions on the Media Center Sandbox blog. I will also summarize the steps here to hopefully make them easier to discover in web searches.
To add a strong name key file to the project assembly:
To add a strong name key to App.xml that is included when you create a new Windows Media Center Presentation Layer application using the Visual Studio 2005 project template:
After using the above steps, you can proceed to create an MSI-based installer for your application using the WiX installer instructions in the step-by-step guide. When installing the MSI, your application assembly should install correctly to the GAC and Media Center will know how to load it because the registration XML file contains the full strong name identity information for your assembly.
Well this week was a nice rest, most of it spent relaxing with my wife. So it was a non-coding week but