Select to view content in your preferred language

Intermittent ArgumentException "Mix spatial references are not supported" on startup

1501
3
Jump to solution
03-27-2013 03:49 PM
markcheyne
Deactivated User
Occasionally when my Silverlight (4) API (v3.1) app starts, I get the following exception:

Source: MapApp.OnUnhandledException()  Message: Mix spatial references are not supported. Parameter name: Envelope.Union    at ESRI.ArcGIS.Client.Geometry.Envelope.Union(Envelope extent)    at ESRI.ArcGIS.Client.LayerCollection.GetFullExtent()    at ESRI.ArcGIS.Client.Map.Layers_LayersInitialized(Object sender, EventArgs args)    at ESRI.ArcGIS.Client.LayerCollection.LayersInitializedHandler.Invoke(Object sender, EventArgs args)    at ESRI.ArcGIS.Client.LayerCollection.calculateLevelScheme(Boolean raiseInitialized)    at ESRI.ArcGIS.Client.LayerCollection.layer_OnInitialized(Object sender, EventArgs args)    at System.EventHandler`1.Invoke(Object sender, TEventArgs e)    at ESRI.ArcGIS.Client.Layer.OnInitialized(EventArgs e)    at ESRI.ArcGIS.Client.Layer.Initialize()    at ESRI.ArcGIS.Client.FeatureLayer.initialize()    at ESRI.ArcGIS.Client.FeatureLayer.featureLayerInfo_OutputReady(Object sender, EventArgs e)    at ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo.OnReady(EventArgs e)    at ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo.Execute_Completed(Object sender, DownloadStringCompletedEventArgs e)    at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)    at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)


You can see from the stack trace that the exception originates inside an API class, not in my code. I never call Union() myself.

This happens at app startup. When it happens, I simply reload the page so that app startup starts over. it may happen a half dozen times in a row, then the app starts fine. Other times the app starts fine the first go.

The actual spatial references of my layers are all the same. But apparently sometimes they don't load correctly and appear different?

Any ideas on how I can handle this without my app completely blowing up?

Thanks, MC
0 Kudos
1 Solution

Accepted Solutions
markcheyne
Deactivated User
got it. some of our map services are published with 'custom' SRs. In reality they are all the same SR, but some were published without setting the map document data frame to one of the canned SRs from ArcMap's picker, which assigns a version of our SR that has an WKID, instead just using the text version of the SR pulled from the ArcSDE layers, which are older and don't record their WKID and thus are 'custom'. These layers come across to the web APIs as if the layer SpatialReference.WKID is 0, while other services published with a WKID come across as nonzero, and the Map does not like that. I had code in the layer initialized event handler to check for these and set them to a nonzero WKID, but a bug with other logic in that handler meant that the check would get skipped depending on the order in which layers were initializing, which of course changes from one execution to the next due to the async nature of things.

whew!

View solution in original post

0 Kudos
3 Replies
markcheyne
Deactivated User
got it. some of our map services are published with 'custom' SRs. In reality they are all the same SR, but some were published without setting the map document data frame to one of the canned SRs from ArcMap's picker, which assigns a version of our SR that has an WKID, instead just using the text version of the SR pulled from the ArcSDE layers, which are older and don't record their WKID and thus are 'custom'. These layers come across to the web APIs as if the layer SpatialReference.WKID is 0, while other services published with a WKID come across as nonzero, and the Map does not like that. I had code in the layer initialized event handler to check for these and set them to a nonzero WKID, but a bug with other logic in that handler meant that the check would get skipped depending on the order in which layers were initializing, which of course changes from one execution to the next due to the async nature of things.

whew!
0 Kudos
MohanRamegowda1
New Contributor
Hi Cheynm,

I am using this API with WPF application and i am new to ArcGIS. Even I am getting the same error in my application. Can you please help me by providing the sample solution file where you have fixed this issue or by providing more information about how to fix this issue.

Thanks,
Mohan
0 Kudos
markcheyne
Deactivated User
had this issue again recently with a different feature class. To diagnose - or at least get a more informative error message - we try to edit the ArcSDE/Oracle feature class in ArcMap. ArcMap will expose the ORA-blahblahblah DBMS error that'll point you towards whatever is actually unhealthy about your feature class. Or maybe. In this case, we got a constraint violation between the B and F table shape/fid, but what actually fixed the issue was an drop/add spatial index and Analyze (the toolbox tool, not the ArcCatalog context menu).

Of course, the 'fix' broke all the spatial views using the feature class because its XY extent had been recalculated. And they are all locked by map services and thus inconvenient to treat. Party on.
0 Kudos