/Home /Archive /Syndicate /Blog /Support /About /Contact  
All Visual Basic Feeds in one place!





Either I am missing something or the information is just not out there in an obvious place.

What I am talking about is deployment of Applications.  Windows, WPF, ASP.NET or Silverlight
it all seems to be the same.  There is plenty of information about how to develop Applications but
deployment seems to be a lacking topic.

I was recently brought into a conversation about Silverlight 2 due to my interest in WPF and an
application that I was developing for where I work.  The application is a WPF page that is run in
the Users web browser and due to this it was suggested that Silverlight may be what I want to
use to develop the application with.  As it turns out due to some limitations, or perhaps a better
reason would be my lack of knowledge, that using Silverlight is not an option for my application
but I am digressing from the topic of this post a little.

My first look at Silverlight was with Silverlight 1.0 as I didn’t have 2.0 downloaded and installed at the time.

There was nothing amazing about the project, just a red rectangle on a page as the whole object
of my looking at Silverlight was to see about what files needed to be uploaded to the web server
so the application could run.  The project consisted of 4 files.  One .html file, one .xaml files,
one .xaml.js  file and one .js file.

I uploaded the four files onto my server and the project ran as it should displaying my red rectangle.

Deploying a Silverlight application seemed pretty easy.  In a way I was right and in a way I was wrong. 
Deploying a Silverlight 1.0 application was easy, but that didn’t seem to be the case when I created
my first Silverlight 2.0 application.

I first knew I was in trouble when I created the application in Visual Studio 2008 and right off the bat
I was given choices of how I wanted to set the application up.

Not being sure what I wanted, and having worked a little with an ASP.NET web site before I chose
that option from the Project Type dropdown box.

My sense of foreboding got worse as I looked at the number of files that resided in the Solution
Explorer window.  Xaml files, xaml.vb files, aspx files aspx.vb files, js files, config files I was
beginning to wonder what I had gotten myself into and how I was going to get myself out.

I pushed ahead and put an Ellipse, a Rectangle and a Button on my Page.xaml.

    1 <UserControl x:Class="SilverlightApplication3.Page"

    2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    4    Width="400" Height="300">

    5     <Grid x:Name="LayoutRoot" Background="White">

    6         <Grid.ColumnDefinitions>

    7             <ColumnDefinition></ColumnDefinition>

    8             <ColumnDefinition></ColumnDefinition>

    9         </Grid.ColumnDefinitions>

   10         <Grid.RowDefinitions>

   11             <RowDefinition></RowDefinition>

   12             <RowDefinition></RowDefinition>

   13         </Grid.RowDefinitions>

   14         <Button Grid.Row="0" Grid.Column="0" Margin="20" Content="Change Colours"

   15                x:Name="Button1" Click="Button1_Click"></Button>

   16         <Ellipse Fill="Blue" Grid.Row="0" Grid.Column="1" Height="100" Width="150"

   17                 x:Name="Ellipse1"></Ellipse>

   18         <Rectangle Height="100" Width="150" Grid.Row="1" Grid.Column="0" Fill="Red"

   19                   x:Name="Rect1"></Rectangle>

   20     </Grid>

   21 </UserControl>

In the code behind page I wired up the Click Event of the Button to swap the colours of the
Ellipse and Rectangle as well as change the Content of the Button.

   10     Private Sub Button1_Click(ByVal sender As System.Object, _

   11                               ByVal e As System.Windows.RoutedEventArgs)

   12 

   13         Ellipse1.Fill = New SolidColorBrush(Color.FromArgb(254, 254, 0, 0))

   14         Rect1.Fill = New SolidColorBrush(Color.FromArgb(254, 0, 0, 254))

   15         Button1.Content = "Colour Changed!"

   16 

   17     End Sub

 Having read through Scott Guthrie’s Silverlight tutorials I knew that when the project
was built there was a .xap file (pronounced “zap”) complied and placed in the ClientBin directory
of the ASP.NET Web Site that would be hosting the Silverlight application.  Sure enough after
building the project the .xap file appeared.

I ran the project and sure enough when my web browser opened there was the Button,
Ellipse and Rectangle all hosted nicely in the .aspx page.

and when I clicked the Button, the colours of the shapes changed as well as the content
of the Button as is it was supposed to.

I was actually no closer to knowing what I needed to upload to my server, but at least
I had a working application.

One thing I did know was that I didn’t really want to have the application run as a ASP.NET
web site on the server and I figured that it had to be able to be run from the .html page or
there would be no reason for the .html page to be created when the project was created.

To test my theory on this I navigated to where the .html page resided on the hard drive and
double clicked on it.  The controls were there when it opened and the application worked like it
should so I knew for a certainty that I didn’t need to have the web site configured as an ASP.NET
web site.

I went back and re-read Scott Guthrie’s tutorial about the .xap file being hosted within the web
page which got me to thinking that the only files I needed to upload were the .html file and the
ClientBin directory and the .xap file that resides in it.

I uploaded the files to my web server, typed in the address of the .html page and ran smack into
an error.  The application would not run.

The error as it turned out was not because of my uploading the wrong files rather it turned out
that I didn’t have the correct MIME type added to the site which was a new one to me.

In order to get a Silverlight application to run on a web site you need to add the correct MIME
type and extension.

The MIME type and Extension are:

MIME type: application/x-silverlight-app
Extension : .xap

Once you have this added to your site, the Silverlight application will run just like it does on the
development machine.

The link in the images is live and you can visit it to see the application in action.

So the short answer to the question "What files do you need to upload to get a Silverlight
application to work on the Internet if you want to host your application in a .html page?"

Files:

.html host page
ClientBin directory and the .xap file that resides in it.

The following MIME Type and Extension must be added to your server:

MIME type: application/x-silverlight-app
Extension : .xap

© 2005 Serge Baranovsky. All rights reserved.
All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.

This site is maintained by SubMain(), a division of vbCity.com, LLC