Silverlight DeploymentPosted by Chris Fuller
Tuesday, April 21, 2009
The first item I wanted to address before I deployed was that I didn't like the SilverSampleTestPage.aspx that was generated for me.
I moved the XAML from SilverSampleTestPage.aspx to Default.aspx and deleted
SilverSampleTestPage.aspx and SilverSampleTestPage.html from my solution. I also made a few minor modifications to the XAML. Figure 1 shows the XAML for the Default.aspx page that hosts the SilverSample client application:
Figure 1 - Default.aspx
The second problem that I ran into was the fact that I was using the default binding and address for my service. In my getCityList() method, (see previous post), I had created an instance of my the proxy like this:
SilverServiceClient proxy = new SilverServiceClient();
The problem with this approach is that when I went to deploy, the address being used was the address of my local host from my service reference definition, (see Figure 2 - Service Reference Definition), and not the address of my QA server.
Figure 2 - Service Reference Definition
To rectify the situation, I added a using statement and static property to App.xaml.cs:
Figure 3 - Changes to App.xaml.cs
Ideally, I would be pulling the address from a .config file, but my understanding is that the Silverlight client doesn't have a .config file concept, (please correct me if I'm wrong and/or if there's a better way to do this). Until I figure out a better way, I'm switching back and forth between the server address and the local address depending on whether I'm working locally or deploying. Not ideal, but it works.
The local address is pulled directly from my local instance of Cassini - see Figure 4. This works because I'm hosting the WCF service within the web project.
Figure 4 - Cassini on client
NOTE: Sometimes over the course of working in Visual Studio, the port # on Cassini changes. When it does, I have to modify the local address for things to work.
OK, so I am ready to deploy. I comment out the local endpoint address and uncomment the address on the server I am deploying to. I then right-click on the SilverSample.Web project and choose "Publish". See Figure 5.
I copied the published files my solution up to my directory on the QA server.
Note: My QA Server is a Windows Server 2003 box running IIS 6.
Ready to go - right? Not so fast...the Silver Gods made me pay some dues first. My next post will explain the issues that I ran into and what I did to work through them.
Check it out - not fancy, but it works: http://www.silversample.com/sample1