Welcome to irritatedVowel.com Sign in | Help

POKE 53280,0: Pete Brown's Blog

Silverlight, WPF, Woodworking, .NET Programming, CNC, Nature, and other topics.

Pete Brown writes on a number of topics including Silverlight, WPF, .NET, woodworking and working as a consultant in the DC area. On most forums, Pete goes by the name Psychlist1972. Pete has worked at Applied Information Sciences (AIS) since 1996 where he currently performs as a lead architect and project manager.

Applied Information Sciences - My Employer



World Domination

who's online

Networks


View Pete Brown's profile on LinkedIn

AddThis Social Bookmark Button
Xap! App! Pow! Packaging and Application Startup in Silverlight 2 Beta 1 - Part 1

This is Part 1 of a two-part series. Part 1 focuses on the new packaging model. Part 2 focuses on application startup and loading.

One of the nicest changes in Silverlight 2 is the addition of the new packaging model for managed code applications. While you can still use the loose file (xaml + JavaScript) methods for JavaScript applications in Silverlight 2, you must use the xap packaging model for managed applications. This is actually a good thing because of everything that xap brings to the table.

pmb_xap_app_comic

We'll keep the scope here to just managed code. However, you can still use the loose file model with JavaScript applications, and DLR projects have an auto-xap function which handles the xap goo for you.

Keep in mind that since this is Beta technology, anything you see here is subject to change.

Xap for Managed Code

Xaps (pronounced "Zaps"). really clean up the deployment of Silverlight applications in Silverlight 2. Under the covers, xap files are simply Zip files with the extension renamed. This allows you to use standard tools to create your own xap files or to inspect the contents of other xaps. This new packaging model also has several other benefits:

  • Compression greatly reduces the size of the download for the user. This is a big deal for performance.
  • The single-file deployment model makes web deployment easier and cleaner
    • If you want to create a portable application (we're doing one of those this spring/summer), all you need to deliver to someone is the xap package and, if they don't have something set up already, the page html markup to display the control
  • You can store the xap in a document library in SharePoint 2007 and serve up your Silverlight content from there. (in 1.1, there were issues with the path names for the DLLs)

To use xap files, make sure you have the mime type for xap application/x-silverlight-app set up in IIS. Under Windows 2008, this mime type is already present.

Also note that the <asp:Silverlight> control supports xaps, so you will be able to use that control right out of the gate. In fact, the default behavior of the project template in Visual Studio 2008 is to use the <asp:Silverlight> control for your test page. If you want the old html activation, check out what gets created in the ClientBin folder and use that.

BTW, "xap" doesn't actually stand for anything. :)

Xap Contents

The xap file itself contains your application DLLs, any assets you have packaged, and the AppManifest.xaml manifest file.

image

(ignore the 0% deflate on one of the DLLs. I understand that is an issue with the Beta 1 build. I would expect to see if addressed in the future)

DLLs

The DLLs are just what you would expect them to be: your compiled application code, targeting the Silverlight .NET framework. They are no longer just loose on the server like they were in 1.1.

Manifest

The xap manifest file (AppManifest.xaml) sets the starting point and lists all the components which make up the application.

Here is an example of the manifest file (the runtime version may not be exactly the same as you have). In this case, there are three DLLs that are included in the xap:

<Deployment 
    xmlns="http://schemas.microsoft.com/client/2007/deployment" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    EntryPointAssembly="PeteBrown.SilverlightWallpaperNavigator" 
    EntryPointType="PeteBrown.SilverlightWallpaperNavigator.App" 
    RuntimeVersion="2.0.30226.2">
  <Deployment.Parts>
    <AssemblyPart 
        x:Name="PeteBrown.SilverlightWallpaperNavigator" 
        Source="PeteBrown.SilverlightWallpaperNavigator.dll" />
    <AssemblyPart 
        x:Name="System.Windows.Controls" 
        Source="System.Windows.Controls.dll" />
    <AssemblyPart 
        x:Name="System.Windows.Controls.Extended" 
        Source="System.Windows.Controls.Extended.dll" />
  </Deployment.Parts>
</Deployment>

 

Content

Note that the content files which appear in the xap do not show up in the manifest. For this reason, it is very easy for you to crack open the xap after compile and add in any additional images you might want to have in there (assuming you somehow reference them in your code). Ideally, you'd do this all through Visual Studio and let it manage it, but this provides just one more level of flexibility for how you build your applications.

Look for an upcoming post (after part 2) that discusses the rules around locating your files and accessing them within the xap.

More to Come

Stay tuned for Part 2

Share this post: Email it! | bookmark it! | digg it! | reddit!
Posted: Wednesday, March 05, 2008 3:14 PM by Pete.Brown
Filed under: , ,

Comments

Christopher Steen said:

Sharepoint No VSE WSS for VS 2008 Until Summer [Via: Tariq ] WPF Podder v2 has been released! [Via:...
# March 6, 2008 2:04 AM

Daniel Moth said:

Decompiling Silverlight 2 Apps � Enter the XAP
# March 9, 2008 2:45 PM

POKE 53280,0: Pete Brown's Blog said:

How paths are resolved in Silverlight 2 can be somewhat confusing. This has come up a lot in the Silverlight.net
# March 9, 2008 10:10 PM

TrackBack said:

Even before tools like Reflector made it easy, decompiling .NET applications has become standard operating procedure. Common reasons to decompile an application include learning how compiler's translate code, working around a library's limitations, or outright stealing another person's work. In the world of web browsers, it is so common that "view source" is a primary means of learning how to program...
# March 11, 2008 8:46 PM

jernej said:

Why do the common dll's like System.Windows.Controls have to be included in the xap file? Are they not already on the client's computer when he installs SL plugin?
# March 12, 2008 5:36 PM

Pete.Brown said:

jernej:

Right now, they are separate for the beta. That's not necessarily the final decision/approach, though.

Pete

# March 12, 2008 7:01 PM

Canadian User Experience said:

It has been three weeks since we annouced Silverlight 2 at MIX08. Many of you are excited to getting
# March 26, 2008 11:49 AM

Tran Thanh Luong said:

Please tell me, how to read and write binary file on webserver (root directory) with Silverlight 2.0. Thanks!
# April 19, 2008 8:50 PM

.Net World said:

When you build a Silverlight 2 application, you compile your source files (inc. XAML and embedded resources
# April 24, 2008 10:19 PM

Sajal said:

How can I add reference of sharepoint dll to xap project.Help!!!
# May 9, 2008 9:04 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the text you see in the image:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS