I have been using ArcObjects since version 10.0 and have been using the same code that is listed in the "Select Map Features by Attribute Query" snippet that comes with the ArcObjects SDK. Attached is the snippet from the SDK. On the call to SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, False), I get the following error:
System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
This works with previous versions 10.0, 10.1, 10.2. What is going on? How do I fix this? If additional information is required, feel free to reply.
Additional notes:
Thanks in Advance
Hi jpgrusling
This is an existing BUG. [BUG-000097730: The QueryFilter does not function, and errors are returned for methods that require IQueryFilter parameters, such as IFeatureClass.Search, IFeatureSelection.SelectFeatures, and so on, in external ArcObjects applications that access ArcMap using the IAppROT interface.]
And below is the workaround for the issue.
Use IObjectFactory.Create to create the QueryFilter object instead of the new keyword to ensure the QueryFilter functions as expected from external applications, as shown in the following code:
IQueryFilter pQF = new QueryFilter();
string classID = pQF.GetType().GUID.ToString("B");
/// appRot application space
IObjectFactory objectFactory = (IObjectFactory)pAPP;
pQF = (IQueryFilter)objectFactory.Create(classID);
For more information about this workaround, refer to the document at http://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#56eba175-54c1-46b4-801a-fc968e582581....
Thanks,
Alif