Debugging Silverlight 1.1 Content in VS Orcas Beta 2
I’ve been digging in to Silverlight 1.1 lately, and I came across an issue where I was unable to load XML from a local (i.e. a “file:///”) URL. (I’m still unable to, by the way — trying to figure out if it’s a sandbox limitation or an incorrectly formed URL). Regardless, I was a little miffed that my Silverlight 1.0 apps automatically launched in a dynamic VS web server, and my Silverlight 1.1 apps did not. I found a great post by Peter Kellner that explains exactly how to set this up.
For my needs, I created an “Empty Web Site” instead of an ASP.NET site. After following the instructions on Peter’s page, be sure to configure your new website as the startup project in VS. Now, when I need to load XML content, I use the code from the Manipulate XML Data in Silverlight HowTo, except that when I determine the correct URL, I add in the port from the DocumentUri:
private string GetUrl()
{
string path = HtmlPage.DocumentUri.AbsolutePath;
int lastSlash = path.LastIndexOf( "/" );
path = path.Substring( 0, lastSlash + 1 );
string port = ":" + HtmlPage.DocumentUri.Port;
return "http://" + HtmlPage.DocumentUri.Host + port +
path + "path/to/file.xml";
}
Even if you’re not running your deployment web server on a non-standard port, the port will resolve to “:80″, which is completely legal.
| TrackbackNo comments yet. Be the first.
Leave a reply

