Skip to main content

Microsoft Silverlight

Answered Question The URI prefix is not recognizedRSS Feed

(0)

markheath
markheath

Member

Member

117 points

63 Posts

The URI prefix is not recognized

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
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Answered Question

Re: The URI prefix is not recognized

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.

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

markheath
markheath

Member

Member

117 points

63 Posts

Re: The URI prefix is not recognized

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!

Mark

 

microsoft_kc
microsof...

Contributor

Contributor

2890 points

564 Posts

Re: The URI prefix is not recognized

Try the following:

client.DownloadStringAsync(new Uri(App.Current.Host.Source, "../playlist.xml"));

Place your playlist.xml file outside the ClientBin directory.

Remember: Please click on "Mark As Answer", if this answered your query partially or fully.


Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities