私のSilverlightプロジェクトは、次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;
}
// (...)
}
Visual Studioから実行すると(デバッグまたはデバッグなしで開始)、すべてが正常に機能しています。しかし、今はVSの外部で起動したいので、実行しましたProjectName.Web/ProjectNameTestPage.html
-dane.xml
ファイルの読み込みに失敗し、MessageBoxから次のエラーが発生しました:
ファイルdane.xmlのロード中にエラーが発生しました
System.Net.WebException:WebClient要求中に例外が発生しました。
---> System.NotSupportedException:URIプレフィックスが認識されません。
System.Net.WebRequest.Create(Uri requestUri)
in System.Net.WebClient.GetWebRequest(Uri address)
in System.Net.WebClient.DownloadStringAsync(Uri address、Object userToken)
(...)URI = dane.xml
それを修正するにはどうすればよいですか?
dane.xml
ソリューションエクスプローラーでリソースとして設定して作成しようとしましnew Uri("ProjectName;component/dane.xml", UriKind.Relative);
たが、VisualStudioで実行すると失敗します。