I am using ArcObjects 10 and when I select a feature using queryFilter I get this exception :

An exception of type 'System.Runtime.InteropServices.COMException' occurred in EMS.exe but was not handled in user code

Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.

This is my code :

 featSel = ems.featureLayer as IFeatureSelection;
 idList = featSel.SelectionSet.IDs;
 featureClass = ems.featureLayer.FeatureClass;
 queryFilter = new QueryFilterClass();
 queryFilter.WhereClause = "code=1088" ;
 selectionSet = featureClass.Select(queryFilter, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);

I get the exception on the last line.

I think this is related to the shapefile version as it worked with ArcGIS 10.4.

  • The "version" of shapefiles hasn't changed since the specification was published in the early 90s. Please Edit your question to specify the exact version of ArcObjects in use ("10" is nearly a score of releases). You should also write about the attempt you have made to verify that the datafile is not corrupt.
    – Vince
    Commented Jun 10, 2018 at 13:23
  • Please delete your comment requesting an answer; lead time on AO answers is closer to two days than two hours (especially on weekends), and statements of urgency result in downvotes and delay.
    – Vince
    Commented Jun 10, 2018 at 13:28
  • thanks.but data is not corrupt and my ArcGIS.Engine is v10.0 . I guess maybe the problem is the version of the shapefile.but you say its not . And unfortunately my situation is an emergency
    – Ahmad.H
    Commented Jun 10, 2018 at 13:35
  • 2
    If it's an emergency, you should be using a supported GIS platform on a supported computing platform, with a 24x365 support contract.
    – Vince
    Commented Jun 10, 2018 at 21:35
  • Does the error occur when if you call Select with null instead of queryFilter? Are you certain 'code' is a numerical field and not a string field? What happens if you delete all the features from the shapefile and try this code again? I know you said your data isn't corrupt, but sometimes features can get messed up in ways that are hard to detect.
    – danielm
    Commented Jun 11, 2018 at 14:59

2 Answers 2


If your data source is of the type shapefile then you need to enclose the field name in it's correct delimiters. In an old project of mine that processed data that was only in Shapefile format the following VB .Net code would work:

' Create a queryfilter
Dim pQueryFilter As IQueryFilter
pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "" & Chr(34) & "batBType" & Chr(34) & "= 'S'"

The whereclause would be:

""batBType" = 'S'"

Note the field name in the whereclause string is surrounded by double quotes.


I find out why this exception occurred. My "code" field type was 'string' when I changed to 'int', it worked perfectly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.