0

いくつかのWCFデータサービスにアクセスするSilverlight4アプリケーションがあります。

ブラウザからサービスにアクセスするのに問題はありません。

信頼性を高めてブラウザ外で実行するようにプログラムを設定しました。次に、フィドラーを介してWCFサービスへの呼び出しを確認できますが、何も返されません。

デバッグすると、次のエラーが発生します。

$exception  {System.UnauthorizedAccessException: Invalid cross-thread access.
   at MS.Internal.XcpImports.CheckThread()
   at System.Windows.Controls.ItemCollection.GetValueInternal(DependencyProperty dp)
   at System.Windows.PresentationFrameworkCollection`1.get_CountImpl()
   at System.Windows.PresentationFrameworkCollection`1.get_Count()
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.RemoveAll()
   at System.Windows.Controls.ItemContainerGenerator.RemoveAll()
   at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
   at System.Collections.ObjectModel.Collection`1.Clear()
   at ClientFolderExplorer.ViewModels.DocumentExplorerViewModel.clientCatalog_ClientsLoadingComplete(Object sender, ClientLoadingEventArgs e)
   at ClientFolderExplorer.Catalogs.ClientCatalog.<>c__DisplayClass3.<ExecuteClientQuery>b__2(IAsyncResult a)}  System.Exception {System.UnauthorizedAccessException}

トラブルシューティングをどこから始めればよいかわからない。Webサーバーのルートにファイルがcrossdomain.xmlありclientaccesspolicy.xmlますが、これらのファイルが要求されていることすらわかりません(フィドラーで)。

何か案は?

4

1 に答える 1

0

はい-問題はクロスサイトアクセスに関連していると思いますが、実際にはクロススレッドアクセスに関連しています(エラーの最初の行はこれを明確に示しています)。

サービス呼び出しを処理するコールバックから直接、UI要素のデータバインドされた(または関係ない)プロパティを設定しようとしていると想定しています。(編集)明確にするのを忘れた-コールバックがUIスレッドとは異なるスレッドで実行されている場所。他のほとんどのフレームワークと同様に、Silverlightでは、UIスレッド以外のUIの変更は許可されていません。

Dispatcherその場合は、UIスレッドに戻すための使用方法を確認してください。

于 2010-11-30T14:38:04.650 に答える