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?