System.Collections.Generic.KeyNotFoundException on FeatureLayer.SaveEdits()

1084
1
08-22-2013 03:42 PM
markcheyne
Occasional Contributor
I'm getting the following exception when I call FeatureLayer.SaveEdits(). My layer has DisableClientCaching set. This only happens on some layers.

[INDENT]
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.  at System.Collections.Generic.Dictionary`2.get_Item(TKey key)  at ESRI.ArcGIS.Client.Tasks.ServiceException.CreateFromJSON(String json)  at ESRI.ArcGIS.Client.Tasks.TaskBase.CheckForServiceError(RequestEventArgs e)  at ESRI.ArcGIS.Client.Tasks.TaskBase.request_Completed(Object sender, RequestEventArgs e)  at ESRI.ArcGIS.Client.WebRequest.OnComplete(RequestEventArgs args)  at ESRI.ArcGIS.Client.WebRequest.uploadStringCompleted(Object sender, UploadStringCompletedEventArgs e)  at System.Net.WebClient.OnUploadStringCompleted(UploadStringCompletedEventArgs e)  at System.Net.WebClient.UploadStringOperationCompleted(Object arg)
[/INDENT]


None of my try/catch will catch this exception - not around the SaveEdits() call, nor in the EndSaveEdits or SaveEditsFailed event handlers. I suppose that means the exception happens in some private portion of the API after SaveEdits() returns but before those events are raised. I can see in Fiddler that the applyEdits request is sent, but I'm not clear if a response is received (Fiddler noob, I can't seem to find responses to anything)

Thanks, MC
0 Kudos
1 Reply
markcheyne
Occasional Contributor
Turns out that I wasn't populating attributes on the graphic for a few non-nullable columns. Although ArcGIS Server gave a meaningful error message to that effect, it appears to nevertheless cause an exception inside the API. By pasting the 'adds' text from the applyEdits request as snagged via Fiddler into the ApplyEdits page of the relevent feature layer using a web browser, I was able to see the response and set myself straight.
0 Kudos