Skip to main content
Home Forums Silverlight Programming Programming with .NET - General The URI prefix is not recognized
3 replies. Latest Post by microsoft_kc on July 15, 2009.
(0)
markheath
Member
117 points
63 Posts
07-15-2009 2:42 AM |
I want to demo a Silverlight app I have written in a situation with no web access. No problem, I thought, just have a html file and my xap file and double-click the html page. However, I get an error whenever I try to use the WebClient to download an XML file that resides in the same folder as the html file:
client.DownloadStringAsync(new Uri("playlist.xml", UriKind.RelativeOrAbsolute));
The error is "The URI prefix is not recognized". I have checked and double-checked the filename. I've put the playlist.xml at the same level as the html, inside the xap, and tried using a ClientBin folder too.
Any suggestions on what is going wrong here? I'm using Silverlight 3 Visual Studio tooling, so my project upgraded itself last time I opened it.
thanks
Mark
tanmoy.r
Contributor
3594 points
710 Posts
07-15-2009 2:53 AM |
Hi,
When you open your html page it opens like C://somedir/yourhtmlfile.html
In that case WebClient will not work.
You need to run the application with from server (like http:// protocol)
For testing create a simple aspx page and have the same html as your html page and run it.
07-15-2009 3:02 AM |
OK, thanks, I was wondering if that might be the problem. The URL was file:///C:/ etc. For the demo I am going to use the test webserver that comes with VisualStudio to serve up my page. Just one more thing to go wrong in the demo though!
microsof...
2890 points
564 Posts
07-15-2009 3:07 AM |
Try the following:
client.DownloadStringAsync(new Uri(App.Current.Host.Source, "../playlist.xml"));
Place your playlist.xml file outside the ClientBin directory.