Today I came across an error - which I thought a tedious task, but it will take less than 5sec to fix. :)
I have a Silverlight UserControl hosted in a Asp.net website. The Silverlight project reads a xml from the Xap package(ClientBin of the hosting application- here asp.net website) using WebClient. I was getting this exception:
This is my code.
This error was caused because the startup project was the Silverlight Project not the Hosting Application. Just make the Hosting Asp.net application as Startup project.
I have a Silverlight UserControl hosted in a Asp.net website. The Silverlight project reads a xml from the Xap package(ClientBin of the hosting application- here asp.net website) using WebClient. I was getting this exception:
"The URI prefix is not recognized"
This is my code.
void wClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result != null)
{
string productList = e.Result;
}
else
{
string Message = "Error Occured";
}
}
public void LoadXml()
{
WebClient wClient = new WebClient();
wClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wClient_DownloadStringCompleted);
wClient.DownloadStringAsync(new Uri("Products.xml", UriKind.Relative));
}
This error was caused because the startup project was the Silverlight Project not the Hosting Application. Just make the Hosting Asp.net application as Startup project.