我有一个访问几个WCF数据服务的Silverlight 4应用程序。
通过浏览器访问服务没有问题。
我将程序设置为使用提升的信任来运行浏览器。然后我可以通过fiddler看到对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}
不确定从何处开始进行故障排除。我在网络服务器的根目录中有crossdomain.xml
和clientaccesspolicy.xml
个文件,但我甚至看不到这些文件被请求(在fiddler中)。
任何想法?
答案 0 :(得分:0)
是的 - 您认为问题与跨站点访问有关,而实际上它与交叉线程访问有关(第一行错误表明这一点)。
我假设您正在尝试直接从处理服务调用的回调设置一些UI元素的数据绑定(或不,无关紧要)属性。 (编辑)忘了澄清 - 回调是在不同于UI线程的线程上运行的。像大多数其他框架一样,Silverlight不允许修改UI,除了UI线程。
如果是这样,请查看如何使用Dispatcher
切换回UI线程。