Select to view content in your preferred language

add-in definition query change causes error/crash in 3.5

359
6
Jump to solution
4 weeks ago
Kevin_Andras
Regular Contributor

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:

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Could-not-initiali...

0 Kudos
1 Solution

Accepted Solutions
Kevin_Andras
Regular Contributor

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.  

 

View solution in original post

0 Kudos
6 Replies
Robert_LeClair
Esri Esteemed Contributor

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.

0 Kudos
Kevin_Andras
Regular Contributor

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.

 

0 Kudos
Kevin_Andras
Regular Contributor

This pops up in Visual Studio when the SetDefintionQuery is called:

Kevin_Andras_0-1747867846911.png

 

0 Kudos
Kevin_Andras
Regular Contributor

I just ran the exact same code on a 3.4 installation and I did not get this error.  

0 Kudos
Kevin_Andras
Regular Contributor

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.  

 

0 Kudos
mikeharol
Occasional Contributor

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);
}

0 Kudos