0

私の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で実行すると失敗します。

4

1 に答える 1

0

問題が解決しました。私は自分のサイトをApacheサーバーに配置し(ProjectName.webフォルダーをコピーして実行しますProjectNameTestPage.html)、動作します。

于 2012-11-09T09:01:48.543 に答える