|
Silverlight Deployment IssuesPosted by Chris FullerTuesday, April 21, 2009 |
My sample application is built in Silverlight and uses a WCF service, hosted in the web application for data access.
My first Silverlight deployment was not very smooth. I had several issues when I went to deploy. The good news is that I was able to work through all of them. Hopefully this post will save others some time.
The first problem I had was a 404 error when I went to http://www.silversample.com/silverservice.svc - see Figure 1.
Figure 1 - 404 Error SilverSample.svc
After some digging, I found that our server is running IIS 6.0 and the .svc extension was not registered. I registered .svc with the following steps:
1. Right-click on the SilverSample site in IIS and choose "Properties"
2. Go to the "Home Directory" tab
3. Click the "Configuration" button
4. Click "Add"
5. In the Executable box, enter: c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll - see Figure 2.
Figure 6 - Application Configuration in IIS 6
This fixed my issue. I could now browse to http://www.silversample.com/silverservice.svc - see Figure 3.
Figure 3 - SilverService.svc
To test the service, I went back to Visual Studio on my local machine, deleted my local service reference and added a service reference that pointed to silverservice.svc on my QA server. See Figure 4.
Figure 4 - SilverServiceProxy Pointing to QA Server
My application ran, but when I clicked the "Test" button which executes the service, I got a strange error: "CommunicationException was unhandled by user code".
See Figure 5.
Figure 5 - CommunicationException error
After some digging, I found
Mark's Blog which pointed me in the correct direction.
I created a new file called clientaccesspolicy.xml and put it in the root of SilverSample site. The clientaccesspolicy.xml file looks like this:
This fixed my issue and I was able to run locally hitting the service.
Note: If you are using a virtual directory under a web site in IIS, the clientaccesspolicy.xml file needs to be put at the root of the site. This is where IIS looks for it. I found this by running Fiddler when working on another project that was using a virtual directory.
Note: This is probably not the configuration you want for a production environment. Below is the configuration I settled on. It allows my application to use the service while preventing public access to the service.
Ok one step closer, one more issue to go. Here is the next error I ran into when I tried to run the SilverSample application from the web server:
This was my 2nd IIS 6 issues. This time I had to add the .xap extension as a Mime Type to my web site in IIS. I right-clicked on the SilverSample site in IIS, went to Properties, then to the HTTP Headers tab and clicked the "MIME Types" button.
Figure 7 shows the MIME Type settings for the .xap file:
Figure 7 - MIME Type Settings for .xap File
That was it! Now everything is worky, worky and I am through my first deployment. Granted this is a simple, make-believe application, but I've worked through a lot of issues that I will know how to deal with when I go to deploy my production application.
1 Comments:
thank you, you save my time.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home