This worked fine in 3.4.
When doing this:
featLayer.SetDefinitionQuery(null);
I get this error (in Visual Studio and in my code's error log), and Arc exits without an error message.
:System.InvalidOperationException: A new active definition query could not be added.
at ArcGIS.Desktop.Internal.Mapping.Operations.SetDefinitionQueryOperation.<Do>b__10_0()
at ArcGIS.Desktop.Internal.Mapping.Utilities.MakeBasicServiceCall(Action serviceCall)
at ArcGIS.Desktop.Internal.Mapping.Operations.SetDefinitionQueryOperation.Do()
at ArcGIS.Desktop.Framework.OperationManager.Do(Operation operation)
at ArcGIS.Desktop.Mapping.BasicFeatureLayer.SetDefinitionQuery(String whereClause)
at NetMapPro.classLayers.<>c__DisplayClass27_1.<<drawReach>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at NetMapPro.classLayers.drawReach(Layer lReach, String Attribute, Int32 Breaknum, String def)
I found another reference to this error on this page:
Solved! Go to Solution.
Looks like if I try to use the code to set the definition query to null when it is already null, I will get this error. I can work around that.
What Add-In are you using? If InfoWater Pro 2026.0.1, then from the link you provided it seems ArcGIS Pro 3.5 is not compatible. Please advise.
I am using my own add-in. I just found that same error message occurs with InfoWater. I'd never heard of InfoWater. Sounds like since two separate add-ins have the same error with 3.5, then something broke from the 3.4 to 3.5 change.
This pops up in Visual Studio when the SetDefintionQuery is called:
I just ran the exact same code on a 3.4 installation and I did not get this error.
Looks like if I try to use the code to set the definition query to null when it is already null, I will get this error. I can work around that.
I had a similar problem. In my case, I was setting a definition query to an empty string when there was no definition query to set. Not a problem in 3.4. What I ended up doing was checking to see if it was empty first.
if (lyr.DefinitionQuery.Length > 0)
{
lyr.SetDefinitionQuery(string.Empty);
}