0

I've created a small ArcObjects app that searches for all matching files in a directory tree and returns the matched files with the number of rows in each file. When performing this loop on a small number of files it seems to process fine. However, when running it over a larger number of files (81), it throws a System.ExecutionEngineException error that I'm having a hard time tracking down. Here is the (allegedly) relevant code.

FYI: The Execute method is thanks to one of Kirk's excellent answers in another question about debugging, I believe.

Following the stack trace of

Multinet Merging Application.exe!Multinet_Merging_Application.shp2gdb_form.Execute(ESRI.ArcGIS.Geoprocessor.IGPProcess proc = {ESRI.ArcGIS.DataManagementTools.GetCount}) Line 460 + 0x10 bytes  C#
Multinet Merging Application.exe!Multinet_Merging_Application.shp2gdb_form.RunCount(string[] inFile = {string[81]}) Line 448 + 0x8 bytes  C#
Multinet Merging Application.exe!Multinet_Merging_Application.shp2gdb_form.SearchAndReport(int option = 1) Line 106 + 0x3a bytes  C#
Multinet Merging Application.exe!Multinet_Merging_Application.shp2gdb_form.searchBtn_Click(object sender = {Text = "Search and Report"}, System.EventArgs e = {X = 125 Y = 13 Button = Left}) Line 326 + 0xd bytes  C#  

Here are the functions--

 private void searchBtn_Click(object sender, EventArgs e)
        {
            if (infolderselected == true && filetypeselected == true)
            {
                string dir = folderTextBox.Text;
                string[] oDir = Directory.GetDirectories(dir);
                if (oDir.Length > 500)
                {
                    if (MessageBox.Show("There are more than 500 directories under this root folder. Are you sure you wish to perform this operation?", "Warning", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        searchrep.Text = searchrep.Text+ "\nSearch canceled!";
                        return;
                    }
                }
        }

private void SearchAndReport(int option)
    {
        string searchstr = type + shpdbf;
        string dir = folderTextBox.Text;
        try
        {
                searchrep.ForeColor = Color.Black;
                setOutputText(searchrep.Text + "\n" + sb.ToString());
                setOutputText(searchrep.Text + "\n--Performing Count. Please wait...");
                setOutputText(searchrep.Text + "\n--Total rows in listed files: " + RunCount(oFiles).ToString());
                setOutputText(searchrep.Text + "\n---------- Search and Report Complete at: " + DateTime.Now.ToString() + " ----------\n");
                searchBtn.Enabled = true;

        }
        catch (UnauthorizedAccessException error)
        {
            MessageBox.Show(error.Message + "\nThis process cannot continue.", "Error");
            setOutputText(searchrep.Text + "\nSearch failed due to error.");
        }
    }
private static int RunCount(string[] inFile)
    {
        finalcount = 0;
        GetCount count = new GetCount();
        foreach (string file in inFile)
        {
            count.in_rows = file;
            Execute(count);
            finalcount += count.row_count;
        }
        return finalcount;
    }
public static void Execute(IGPProcess proc)
    {
        Geoprocessor gp = new Geoprocessor();
        gp.AddOutputsToMap = true;
        gp.OverwriteOutput = true;
        gp.RegisterGeoProcessorEvents((IGeoProcessorEvents)new GPEvents());
        IGeoProcessorResult2 result = gp.Execute(proc, null) as IGeoProcessorResult2;
        IGPMessages msgs = result.GetResultMessages();
        for (int i = 0; i < msgs.Count; i++)
            Debug.Print("{0} {1}", msgs.GetMessage(i).Description, msgs.GetMessage(i).Type);
    }

Apologies, that seems excessive. The gist of the process is that I am attempting to use the Get Count GP tool to return the number of rows from all the files returned in the search. It runs peachy until the number of files returned gets to a certain point, and then it goes kaput. Any ideas?

1 Answer 1

0

ExecutionEngineExceptions are supposedly one of the deadly exceptions you should never see when programming in .NET and is a sign of an unrecoverable error in the underlying language runtime (or something). I ended up "fixing" the issue by creating another project and writing the code over again.

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.