Click here to Skip to main content
11,789,706 members (63,194 online)
Click here to Skip to main content

Does your Silverlight application really have to end in .XAP?

, 21 Jan 2011 CPOL 7.7K 3
Rate this:
Please Sign up or sign in to vote.
We will explore if a Silverlight application must end in .XAP.


We have heard it in books by speakers and even Microsoft: "When hosting a Silverlight application, make sure your file ends in .XAP". But does it really have to end in .XAP?


The answer

The answer is surprisingly no. It is time to end the myth that when hosting a Silverlight application, it has to end in .XAP. Let's look at a sample Silverlight project first.

File-> New Project

When you create a new Silverlight Project and inspect the ClientBin folder, you will see that the filename ends in .XAP.


What do you think would happen if we renamed this file to .zip and updated our hosting page to look like the following?

<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," 
           type="application/x-silverlight-2" width="100%" height="100%">
  <param name="source" value="ClientBin/"/>
  <param name="onError" value="onSilverlightError" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="4.0.50826.0" />
  <param name="autoUpgrade" value="true" />
  <a href="" 
     style="text-decoration:none"><img src="" 
     alt="Get Microsoft Silverlight" style="border-style:none"/>
</object><iframe id="_sl_historyFrame" 

OK, now this is interesting.

If we run the application, it works just like it does with the file named .XAP. We can view the page source on the Silverlight application and verify this.

Let's examine what happened to our actual Silverlight Project. A new .XAP file was created, but it left our .ZIP alone.


Let's try another extension

If it works with .zip, what about any other extension? Let's try a bogus extension like .MIKE. As you can see below, that works too.

What about the Silverlight Project properties?

So now you are probably thinking, can't we can change the filename in the Silverlight project and it will stick right? The answer is, you can, but it will change itself back after you save the project.

Default filename: EndInXapIsCrap.xap.


New file name - notice the .zip file:


After you save the project, it automatically appends .xap to whatever filename you entered (


So, what is the point of all of this?

Well, if the server doesn't allow adding MIME types, then you can rename to whatever extension you choose. You can also setup a post-build event to run a batch file or whatever and rename the .XAP back to whatever extension we want. This is a very nifty trick that I hope someone finds useful.

Subscribe to my feed.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Telerik
United States United States
Michael Crump is a Silverlight MVP and MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

He has worked at Fortune 500 companies where he gained experience in embedded systems design and software development to systems administration and database programming, and everything in between.

His primary focus right now is developing healthcare software solutions using Microsoft .NET technologies. He prefers building infrastructure components, reusable shared libraries and helping companies define, develop and automate process standards and guidelines.

You can read his blog at: or follow him on Twitter at @mbcrump.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Kunal_Chowdhury21-Jan-11 6:13
mvpKunal_Chowdhury21-Jan-11 6:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1509028.1 | Last Updated 21 Jan 2011
Article Copyright 2011 by mbcrump
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid