"Cannot call this method in this context"

10-15-2019 03:19 PM
Occasional Contributor

Is it possible to query features using ServiceFeatureTable without a map? Is there a Query Task that doesn't require using a map or any sort of user interactin?

I tried the C# code that is part of the WPF sample. The sample works as is, but I don't want the map.

I get an error "Cannot call this method in this context: Object failed to load, unable to execute task"

// basically

private async void QueryStateFeature()
   ServiceFeatureTable _featureTable = new ServiceFeatureTable(new Uri(_gisUrl));

   QueryParameters queryParams = new QueryParameters();
   queryParams.WhereClause = "somefield='1234'";
   // await _featureTable.LoadAsync(); // doesn't work

   // here's where the error occurrs

   FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);


0 Kudos
1 Reply
Esri Contributor

Hi Gregory, 

I would recommend querying the REST endpoint directly. Here is a sample I created that does a query with no map: https://codepen.io/benesri/pen/XWWKbwK 

0 Kudos