1

I am developing a stand alone application that at some point needs to run Dissolve on a subset of data in a feature class. This code works for me without issue, regardless of workstation. When another user tries to run the tool at their workstation they get an error. I've tried clearing out all their local ESRI files, but to no avail, so my inclination is that this is some difference in their user profile on our network, but I'm not sure since the error message doesn't appear helpful.

What I'm doing is creating a feature layer, selecting features on that layer, and then handing the layer to the Dissolve geoprocessor tool. For other users the geoprocessor will say that the input does not exist.

void doDissolve(IFeatureClass fc)
{
    string subtype_field = "subtype";

    //create selection query
    IQueryFilter filter = new QueryFilter();
    filter.WhereClause = $"{subtype_field}={Constants.BUILDING_SUBTYPE} AND {Constants.OTHER_SEARCH}";

    //create a layer where only the filtered features are selected
    IFeatureLayer fLayer = new FeatureLayer();
    (fLayer as IDataLayer).DataSourceName = (fc as IDataset).FullName;
    (fLayer as IDataLayer).Connect((fc as IDataset).FullName);
    (fLayer as IFeatureSelection).SelectFeatures(filter, esriSelectionResultEnum.esriSelectionResultNew, false);
    fLayer.Name = "Temp_Layer";

    //create dissolve output directory and file name
    string dissolve_dir = System.IO.Path.Combine(Environment.GetFolderPath(
                                      Environment.SpecialFolder.LocalApplicationData),
                                     "SomeUniqueName");
    string dissolve_name = $"dissolve_{DateTime.Now.ToString("yyyy_MM_dd")}";

    if (!Directory.Exists(dissolve_dir))
        Directory.CreateDirectory(dissolve_dir);

    //create and run Dissolve
    var dissolve = new Dissolve();
    dissolve.in_features = fLayer;
    dissolve.out_feature_class = System.IO.Path.Combine(dissolve_dir, dissolve_name + ".shp");
    dissolve.multi_part = "SINGLE_PART";
    runGP(dissolve);
}

void runGP(IGPProcess process)
{
    try { _gp.Execute(process, null); }
    catch(Exception e)
    {
        StringBuilder messages = new StringBuilder($"{process.ToolName} Messages:\r\n");
        for (int i = 0; i < _gp.MessageCount; i++)
            messages.AppendLine(_gp.GetMessage(i));
        throw new Exception(messages.ToString(), e);
    }
}

The error message is as follows:

ERROR 000732: Input Features: Dataset Temp_Layer does not exist or is not supported

Any ideas on what could be causing this issue?

1

Couple of things really that spring to mind:

  1. If it works fine for you but not for another user then the only thing I can spot in your code that may be user specific is when you get hold of the SpecialFolder. May be they have some security policy that is not allowing them to retrieve a folder location? Try checking dissolve_dir resolves to something sensible?

  2. As the error message seems to be about the layer I wonder if it is the way you are creating the FeatureLayer? You pass in a FeactureClass but then seem to do an unnecessary link to data source name. May be its something to do with that? Here is an example in VBA of creating a FeatureLayer from an existing FeatureClass:

Public Sub test()
    Dim s As String
    s = "C:\Scratch\fGDB_Scratch.gdb\rivers"
    Dim putil As IGPUtilities
    Set putil = New GPUtilities
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = putil.OpenFeatureClassFromString(s)

    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = New FeatureLayer
    Set pFeatureLayer.FeatureClass = pFeatureClass
    pFeatureLayer.Name = "wombat"

    Dim pmxd As IMxDocument
    Set pmxd = ThisDocument
    Dim pmap As IMap
    Set pmap = pmxd.FocusMap
    pmap.AddLayer pFeatureLayer
End Sub
| improve this answer | |
  • Thanks for the help. Unfortunately with all the quarantines it will be a while before I can try this out. – danielm Apr 6 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.