Select to view content in your preferred language

Proper way to handle errors generated by the Map control

641
3
05-31-2011 08:45 AM
MarkCollins
Frequent Contributor
Hello,

I am wondering what the proper/recommended approach is for handling errors generated by the map control? I have attached a screenshot of an example of the exception I am experiencing occasionally if there is an error loading the basemaps. Since the code in my application is not creating the exception, its the map control, what is the best way to handle this?

Thanks,
Mark
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
I am not sure if you are hitting this same bug: http://forums.arcgis.com/threads/25616-ArgumentNullException-%28center%29-in-Map.zoomAbout%28%29-cli.... The stack trace seem the same. This bug is fixed for v2.2. A workaround is included in the related thread.
0 Kudos
MarkCollins
Frequent Contributor
Thanks for the answer. That thread does contain the same issue. Glad to hear the bug is fixed. I will be using this code until I get the chance to update my reference to the API....

void MyMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
 e.Handled = MyMap.Layers.Count == 0;
}
0 Kudos
RichardWatson
Deactivated User
We add an attached property to the various layers which indicates whether or not the layer is required.  If the layer is required and it fails to load then we fail the application.
0 Kudos