我的Silverlight項目使用dane.xml
文件,該文件位於ProjectName.Web/Client.Bin/dane.xml
Silverlight的開放相對URI - 工程調試時,發生故障VS
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;
}
// (...)
}
一切工作正常,當我從Visual Studio運行(Debug或外運行時開始不調試)。加載文件dane.xml
System.Net時
錯誤:和裝載
dane.xml
文件失敗,並顯示以下錯誤來自MessageBox的 - 但是,現在,我想啓動VS外面,所以我跑ProjectName.Web/ProjectNameTestPage.html
。 WebException:WebClient請求期間發生異常。
---> System.NotSupportedException:無法識別URI前綴。
在System.Net.WebRequest.Create(URI requestUri)
在System.Net.WebClient.GetWebRequest (URI地址)
在System.Net.WebClient.DownloadStringAsync(URI地址,對象userToken)
(.. 。)URI = dane.xml
我應該怎麼做才能解決這個問題?
我已經嘗試在解決方案資源管理器中將dane.xml
設置爲資源並創建new Uri("ProjectName;component/dane.xml", UriKind.Relative);
,但在Visual Studio上運行時會失敗。