I'm trying to run the Merge tool using ArcObjects c# .Net. I'm fairly new to the skill but I have been able to run other tools such as Buffer and Points to Line. However, I have met my match with Merge because it requires more than one input (two layers). Would anyone have an idea how I'm suppose to put two layers into "MergeTool.inputs"? I think right now, my Layer1 is being replaced by Layer2 so when the tool runs, I end up with just one layer being merged into nothing and I get the same layer returned.

IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument;
        IMap map = pMxDoc.FocusMap;

        Geoprocessor GPMerge2 = new Geoprocessor();

        ESRI.ArcGIS.DataManagementTools.Merge MergeTool = new ESRI.ArcGIS.DataManagementTools.Merge();

        MergeTool.inputs = Layer1;
        MergeTool.inputs = Layer2;
        MergeTool.output = OutputName;

        GPMerge2.Execute(MergeTool, null);

Edit: I've seen some solutions to use semicolon and quotes. Something like MergeTool.inputs = "Layer1;Layer2" But I'm actually using some variables and I can't get the exact path to the layers to make it into a string. The difference can be seen below if I try to do that. I also want to try and keep this set of code if possible and not set up parameter array.

enter image description here

  • 1
    How and where are you setting the Layer1 and Layer2 parameters?
    – Dowlers
    Jul 25, 2017 at 22:10
  • What version of ArcGIS are you writing for? Your reference seems to be quite old... have a look at resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/… about executing a tool with IGeoProcessor2 interface with arguments as IVariantArray. Jul 25, 2017 at 22:21
  • Usually when you have several inputs, they are separated by commas. If I've ever had a question on what the parameters of a tool are, I would run in manually in the toolbox and examine the results. I use your method of adding parameters instead of using IVariantArray in the geoproccessing tools I write
    – kenbuja
    Jul 25, 2017 at 23:53
  • Here is more information on the inputs. I made global variables that are set up earlier in the code. MergeTool.inputs = GlobalVariables.Layer1 and MergeTool.inputs = GlobalVariables.Layer2. I tried doing something like MergeTool.inputs = GlobalVariables.Layer1, GlobalVariables.Layer2 but that didn't work. As far as my Arc Version, I'm working in 10.3.1 but I'm new to developing add-ins so I'm probably not utilizing the most up-to-date method. I just use whatever reources I come across in google searches.
    – GISense
    Jul 26, 2017 at 12:40
  • Possible duplicate: gis.stackexchange.com/questions/17930/…
    – mkennedy
    Jul 26, 2017 at 18:07

1 Answer 1


@mkennedy suggestion of Using Merge GeoProcess task in ArcGIS Engine with C#? wasn't the same example but I was able to get a hint from it.

This wasn't working for my input:

MergeTool.inputs = "Layer1;Layer2"

But this worked:

MergeTool.inputs = Layer1 + ";" + Layer2

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.