Xml Silverlight打开相对URI-在调试时工作,在VS外部运行时失败
我的Silverlight项目使用Xml Silverlight打开相对URI-在调试时工作,在VS外部运行时失败,xml,silverlight,silverlight-3.0,Xml,Silverlight,Silverlight 3.0,我的Silverlight项目使用dane.xml文件,该文件位于ProjectName.Web/Client.Bin/dane.xml private void ReadXML() { WebClient client1 = new WebClient(); client1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client1_DownloadStringCompleted);
dane.xml
文件,该文件位于ProjectName.Web/Client.Bin/dane.xml
private void ReadXML()
{
WebClient client1 = new WebClient();
client1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client1_DownloadStringCompleted);
link = new Uri("dane.xml", UriKind.Relative);
client1.DownloadStringAsync(filePath);
}
void client1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.ToString() + "\n\nURI=" + link.ToString());
return;
}
// (...)
}
当我从VisualStudio运行它时,一切正常(调试或不调试启动)。但现在我想在VS之外启动它,所以我运行了ProjectName.Web/projectnametspage.html
,加载dane.xml
文件失败,MessageBox出现以下错误:
加载文件dane.xml时出错
System.Net.WebException:WebClient请求期间发生异常。--->System.NotSupportedException:无法识别URI前缀。
在System.Net.WebRequest.Create(Uri requestUri)中
在System.Net.WebClient.GetWebRequest(Uri地址)中
在System.Net.WebClient.DownloadStringAsync(Uri地址,Object userToken)中
(……) URI=dane.xml 我该怎么做才能解决这个问题
我已经尝试在解决方案资源管理器中将
dane.xml
设置为资源,并创建新Uri(“ProjectName;component/dane.xml”,UriKind.Relative)代码>,但在Visual Studio上运行时失败。问题已解决。我已经将我的站点放在apache服务器上(复制ProjectName.web
文件夹并运行ProjectNameTestPage.html
),现在它可以工作了