rnatalie

Threading Errors in ArcGISLocalDynamicMapServiceLayer

Discussion created by rnatalie on May 1, 2013
Latest reply on May 3, 2013 by ahigh2
If I write a rather simple version that follows the example, these load into my map fine.

If I try to create these in a com control, I get an InvalidOperationException from the Dependency Object being invoked in the wrong thread.    Of course, it's way down in the bowels of the service diddling the Url:

> WindowsBase.dll!System.Windows.Threading.Dispatcher.VerifyAccess() + 0x4a bytes 
  WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x15 bytes 
  ESRI.ArcGIS.Client.dll!ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.Url.set(string value) + 0x2b bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.ArcGISLocalDynamicMapServiceLayer.CompleteServiceInitialize(ESRI.ArcGIS.Client.Local.LocalMapService service) + 0xba bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.GetServiceAsyncInternal.AnonymousMethod__0(object s, System.ComponentModel.AsyncCompletedEventArgs e) + 0x4b bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalService.OnStartCompleted() + 0x76 bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.UpdateMapServicePropertiesCompleteStart.AnonymousMethod__c(ESRI.ArcGIS.Client.Local.LayersInfo layersInfo, ESRI.ArcGIS.Client.Local.Internal.RequestInfo requestInfo2) + 0x48b bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.ProcessResponse<ESRI.ArcGIS.Client.Local.LayersInfo>(string url, string queryParameters, System.Exception err, bool cancelled, string result, System.Action<ESRI.ArcGIS.Client.Local.LayersInfo,ESRI.ArcGIS.Client.Local.Internal.RequestInfo> callback) + 0x2d0 bytes 
  ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.Start<ESRI.ArcGIS.Client.Local.LayersInfo>.AnonymousMethod__3(object s, System.Net.DownloadStringCompletedEventArgs e) + 0x186 bytes 
  System.dll!System.Net.WebClient.OnDownloadStringCompleted(System.Net.DownloadStringCompletedEventArgs e) + 0x15 bytes 
  System.dll!System.Net.WebClient.DownloadStringOperationCompleted(object arg) + 0x2a bytes 
  mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e bytes 
  mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes 
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes 
  mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes 
  mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 bytes 
  mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes 
  [Native to Managed Transition] 


I've tried routing the code that does all this to the same thread that the MainWindow (and the ArcGISRuntime.Initialize) is run in and it doesn't help.

Any ideas.

Outcomes