Issues with ArcObjects and ArcGIS 10.1 SP1 IDataStatistics

4313
14
11-21-2012 03:49 AM
DavidWilton
Occasional Contributor
I currently have a case open with ESRI helping us to resolve this. I'm posting here because of the large amount of time it took to find this issue to help others. I have been experiencing a significant number of seemingly random crashes with ArcGIS 10.1 SP1. The issue has been narrowed down to IDataStatistics and IEnumerator (you must loop through the statistics with the enum to cause issue). Running statistics more than once (on different layers or the same layer) can cause a complete crash of ArcMap. It is random as to how many uses of IDataStatistics  will cause the crash, often three or four uses but sometimes as many as 100 which gives the error its random nature. It also causes strange issues with the UI, in the sample code the values are added to a list view which will suddenly switch to foreign characters. Errors we have received since updating to SP1 include System.AccessViolationException (Attempted to read write protected memory), 'FatalExecutionEngineError', 'Assert Failure' and �??ExecutionEngineException�?�. Tested on 32 and 64bit versions of Windows 7 and 32 bit XP

Tested the code without SP1 and it is fine. We have submitted this to ESRI UK and we are awaiting feedback.

Paste bin of the test code submitted to ESRI UK
http://pastebin.com/A4cuQc2u

Has anyone else working with ArcObjects been receiving issues? I will post back when ESRI do

Dave
0 Kudos
14 Replies
RobertHauck
New Contributor
You guys rock.  Getting rid of IDataStatistics in our add-in saved us many hours of Arcmap re-installs.  I gave up trying to find the cause of our crashes until finding this thread. I would of never tracked it down myself.  Thank you for posting your findings.
0 Kudos
DavidWilton
Occasional Contributor
You guys rock.  Getting rid of IDataStatistics in our add-in saved us many hours of Arcmap re-installs.  I gave up trying to find the cause of our crashes until finding this thread. I would of never tracked it down myself.  Thank you for posting your findings.


Thanks appreciate it. Did you see the other thread where I posted a helper so you don't have to remove the code?

http://forums.arcgis.com/threads/70997-ICursor-issue-in-10.1-SP-1
0 Kudos
PrestonMcCormick
New Contributor II
There is a good solution to this problem in the new IQueryFilterDefinition2 interface in 10.1.  I can confirm that this works for file geodatabases and performs well.

            
            IQueryFilter2 query = new QueryFilterClass();
            query.WhereClause = whereClause;
            query.SubFields = distinctColumn;

            IQueryFilterDefinition2 queryDef = (IQueryFilterDefinition2)query;
            string prefixTemplate = "DISTINCT {0}";
            queryDef.PrefixClause = String.Format(prefixTemplate, distinctColumn);
            string postfixTemplate = "ORDER BY {0}";
            queryDef.PostfixClause = String.Format(postfixTemplate, distinctColumn);
0 Kudos
RichardMarlow
New Contributor
Just for info, this IDatastatistics bug has been fixed in 10.2:

http://downloads.esri.com/support/downloads/other_/102-IssuesAddressedList.pdf
NIM087476

Cheers, Rich
0 Kudos
AllanMills
New Contributor III
There is a good solution to this problem in the new IQueryFilterDefinition2 interface in 10.1.  I can confirm that this works for file geodatabases and performs well.

            
            IQueryFilter2 query = new QueryFilterClass();
            query.WhereClause = whereClause;
            query.SubFields = distinctColumn;

            IQueryFilterDefinition2 queryDef = (IQueryFilterDefinition2)query;
            string prefixTemplate = "DISTINCT {0}";
            queryDef.PrefixClause = String.Format(prefixTemplate, distinctColumn);
            string postfixTemplate = "ORDER BY {0}";
            queryDef.PostfixClause = String.Format(postfixTemplate, distinctColumn);


This code sample doesn't quite work for me when I covert it to VB .NET. The problem is with these lines:
            
            string prefixTemplate = "DISTINCT {0}";
            queryDef.PrefixClause = String.Format(prefixTemplate, distinctColumn);


It puts the unique field name after the distinct clause, but that field name is already being fed in the SQL statement being run by the SubFields setting. Setting the prefix to just "DISTINCT" seems to work.
0 Kudos