ArcGISException: Not found: Field does not exist.

1642
3
04-18-2017 07:40 AM
LucianoCampos
New Contributor

Hello,

I have been struggling with a weird exception lately. My context:

- Xamarin Forms (testing on a Android device)
- Basemap/BaseLayers loaded successfully
- While loading some feature tables from a SQLite geodatabase (multiple tables are loaded properly except by two similar ones)

Relevant parts:

try
{
    var geodatabase = await Geodatabase.OpenAsync(<path>);
    var featureTables = geodatabase.GeodatabaseFeatureTables;
    foreach (var featureTable in featureTables)
    {
        var featureLayer = new FeatureLayer(featureTable);
        featureLayer.Name = featureTable.TableName;
        _mapView.Map.OperationalLayers.Add(featureLayer);  //Exception thrown on the ase_ctaponto and ase_cteponto
    }
}
catch (Exception ex)
{
    throw ex; //Breakpoint here
}

The exception:

Type: ArcGISException
Message: "Not found: Field does not exist."
ErrorCode: 7
InnerException: (null)
StackTrace:
 
  at Esri.ArcGISRuntime.ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException) [0x00013] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at RuntimeCoreNet.GeneratedWrappers.Interop.CheckError (System.IntPtr errorHandle, System.Boolean throwOnFailure, System.Runtime.InteropServices.GCHandle wrapperHandle) [0x0002e] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at RuntimeCoreNet.GeneratedWrappers.CoreVector.Insert (System.Int64 position, RuntimeCoreNet.GeneratedWrappers.CoreElement value) [0x00020] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at Esri.ArcGISRuntime.RuntimeCollection`1.InsertItem (System.Int32 index, T item) [0x00064] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at Esri.ArcGISRuntime.RuntimeObservableCollection`1.InsertItem (System.Int32 index, T item) [0x0000d] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at Esri.ArcGISRuntime.RuntimeCollection`1.Add (T item) [0x00007] in <687a544c38e8410dbac0acfc0843ba7e>:0
  at TEST.LoadMapBehavior+<CarregarCamadasEditaveis>d__41.MoveNext () [0x0049d] in Path/MyFile.cs:198

We tried regenerate the geodatabase file multiple times, both on ArcMap desktop and inside the app using ArcGis rest services API.

What I am missing? If I failed to provide sufficient information about the problem, please let me know.

0 Kudos
3 Replies
ChadYoder1
Occasional Contributor II

Are those fields used for labeling or a definition expression?

The fields may not be loaded, you could try to add the code below before you add the layer to the map.

if (ftrLayer.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded)
    await ftrLayer.LoadAsync();‍‍
0 Kudos
JenniferNery
Esri Regular Contributor

I was able to reproduce "Not found: Field does not exist." only if TableName is accessed before layer is added to map with v100.0. Note also that TableName is null until table is loaded. 

However, I'm not able to reproduce this with latest version of the sdk so bug have been fixed in the upcoming update. The following code should also apply with Xamarin.Forms. You can replace MessageBox with DisplayAlert and use different path to geodatabase. InitialViewpoint and subscription to LayerViewStateChanged were added to show that there seems to be no problem loading and rendering your data.

        public MainWindow()
        {
            InitializeComponent();

            MyMapView.LayerViewStateChanged += MyMapView_LayerViewStateChanged;
            MyMapView.Map = new Map()
            {
                InitialViewpoint = new Viewpoint(new Envelope(665409.625723681, 7183296.13943517, 680649.625739226, 7191217.76444325, new SpatialReference(29192)))
            };
        }

        private void MyMapView_LayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)
        {
            var error = e.Layer?.LoadError ?? e.LayerViewState.Error;            
            if (error != null)
                MessageBox.Show(error.Message);
            if (e.LayerViewState.Status == LayerViewStatus.Active)
                MessageBox.Show($"{e.Layer.Name} is now active.");
        }

        private async void Open_Click(object sender, RoutedEventArgs e)
        {
            try
            {                
                var geodatabase = await Geodatabase.OpenAsync(@"C:\asegeo\asegeo.geodatabase");
                var sb = new StringBuilder();
                foreach (var table in geodatabase.GeodatabaseFeatureTables)
                {
                    await table.LoadAsync();
                   sb.AppendLine($"Adding {table.TableName} with {table.NumberOfFeatures} features to map.");
                    MyMapView.Map.OperationalLayers.Add(new FeatureLayer(table));
                }
                MessageBox.Show(sb.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Interestingly, re-ordering line#'s 29-30 above to below also works even in v100.0. Will this workaround be good for you meanwhile?

MyMapView.Map.OperationalLayers.Add(new FeatureLayer(table));
await table.LoadAsync();
sb.AppendLine($"Adding {table.TableName} with {table.NumberOfFeatures} features to map.");‍‍‍


Thanks.

0 Kudos
LucianoCampos
New Contributor

Hey Chad! Thanks for you answer.

 

We tried your suggestion without any lucky, but your hint about labeling got us digging into the right path. One thing led to another and we managed to find a Rotation Expression with a wrong field name.

 

For those reading this, I set the FeatureLayer Renderer property to null trying to isolate the issue. Somehow, the feature layer could be added to the Map OperationalLayers. I did some debugging and found out the RotationExpression with some unexpected fields. Turns out that some Copy/Paste was the culprit.

 

Hey Jennifer! Thanks for your attention too.

 

Interesting behavior you found with the new build. I wouldn’t say it was a bug, because my symbology had this incorrect setting.

 

Btw, ESRI, please improve your error messages. It would be helpful to have, in this case, a message pointing out to “where” this wrong field appear.

 

Thanks again.

0 Kudos