初めてSilverlightを使用する!オンラインチュートリアルに続いて。私はWebClientを使ってDiggのWebサイトからストーリーを検索し、Silverlightコントロールのデータグリッドにそれらを表示するためのアプリケーションを作成しています。ここでWebClient.DownloadStringAsync Silverlightでセキュリティ例外をスローする
はコードです:
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
string topic = txtTopic.Text;
string diggUrl = String.Format("http://services.digg.com/stories/topic/{0}?count=20&appkey=http%3A%2F%2Fscottgu.com", topic);
WebClient diggService = new WebClient();
diggService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(diggService_DownloadStringCompleted);
diggService.DownloadStringAsync(new Uri(diggUrl));
}
void diggService_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
DisplayStories(e.Result);
}
}
私はdiggService_DownloadStringCompleted
イベントハンドラにブレークポイントを置き、常にメッセージと同じの内部例外なしでSystem.Security.SecurityExceptionに等しいe.Error
検索ボタンをクリックするたびに「セキュリティエラー」というメッセージが表示されます。システムでSystem.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod、オブジェクトの状態)で
System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(たIAsyncResult asyncResult)で
:スタックトレースであります私はpeoplを見てきたいくつかの重いグーグル後System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResultインター結果)で.Net.WebClient.GetWebResponse(WebRequestクラス要求、IAsyncResultインター結果)
eはcrossdomain.xmlファイルに言及します。これが何であるかは完全にはわかりませんが、Silverlightコントロールanyを実行しているWebサーバーのルートディレクトリに1を追加し、次のテキストを追加しました。違いはありませんでした:
<?xml version="1.0" ?>
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
どうしていますか?
これを解決しましたか?私は同じ問題を抱えています – Andrew