Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to ArcEngine and ArcObjects. I'd like to develop an extension for ArcMap where I have to use IHookHelper instead of AxMapControl. I am looking for the AddShapefile method, which is available for AxMapControl, but apparently missing from the IHookHelper interface.

public partial class conversionRtoP : Form
    public IHookHelper phookhelperRtoP;
    public IRaster praster;

    public conversionRtoP()

    private void conversionRtoP_Load(object sender, EventArgs e)
        for (int i = 0; i < phookhelperRtoP.FocusMap.LayerCount; i++)
            if (phookhelperRtoP.FocusMap.get_Layer(i) is IRasterLayer)

    private void button1_Click(object sender, EventArgs e)
        Geoprocessor gp = new Geoprocessor();
        IConversionOp pconversionop;
        pconversionop = new RasterConversionOpClass();

        for (int i = 0; i < phookhelperRtoP.FocusMap.LayerCount; i++)
            if (phookhelperRtoP.FocusMap.get_Layer(i).Name == comboBox1.Text)
                praster = (IRaster)phookhelperRtoP.FocusMap.get_Layer(i);

        ESRI.ArcGIS.ConversionTools.RasterToPolygon prastertopoly = new RasterToPolygon(praster, outputpathtext);
        ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult gpresult;
        gpresult = (IGeoProcessorResult)gp.Execute(prastertopoly, null);
        int j;
        string gppath;
        gppath = outputpathtext.Text;
        j = gppath.LastIndexOf("\b");
        // this is my problem:
        ***phookhelperRtoP.(where is addshapefile method)***

    private void button3_Click(object sender, EventArgs e)
        SaveFileDialog savedialog = new SaveFileDialog();
        savedialog.CheckFileExists = true;
        savedialog.Filter = "Shapefile (*.shp)|*.shp";
        savedialog.Title = " Save";
        savedialog.RestoreDirectory = true;
        savedialog.FileName = comboBox1.Text;
        DialogResult dr = savedialog.ShowDialog();
        if (dr == System.Windows.Forms.DialogResult.OK)
            outputpathtext.Text = savedialog.FileName;
share|improve this question
(1) Work on your accept rate! (2) Next time, please take the time to select only the relevant bits of code, and format/indent it in a way that makes it easy to read. – stakx Feb 17 '12 at 14:07

You seem to work with Windows Forms. Can't you put a MapControl control onto your form? (Check the toolbox in the Windows Forms designer, there should be a category for ESRI controls.)

That control supports the various IMapControl interfaces (e.g. IMapControl4) which have an AddShapeFile method.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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