Hello,
I have made a Silverlight program to get custom entity attribute from CRM. While running the application, a message appeared stating the invalid cross access.

System.UnauthorizedAccessException Message: Invalid cross-thread
access.
Stack: at MS.Internal.XcpImports.CheckThread()
at System.Windows.DependencyObject.SetValueInternal
(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.DependencyObject.SetValue(DependencyProperty
dp, Object value)
at System.Windows.Controls.DataGrid.set_ItemsSource(IEnumerable
value)
at Vehicle_Symbol.MainPage. <RetrieveSymbol>b_1
(DataServiceCollection ' 1 results)
Retrieve Symbol Delete
Can anybody analyze this for me? What’s wrong with my program?
What should I do?
Thanks.
- Login or Signup Now to post comments

Hallo Anna,
To be able to get easy cross thread access with the CheckAccess call, you will need to wrap up a utility method in a static class, for instance the following:
After that, you can go ahead and then wrap any calls that update the user interface where you may be on a background thread as done in the following thread:
Once you do it that way, you will not need to know whether you are on a background thread or not and it prevents the overhead caused by adding methods to every control to check this.
Regards,
Carl