Errors when running Hillshade tool from within Visual Basic.Net code

Discussion created by makankuat on May 30, 2013
Latest reply on Jun 3, 2013 by matoretta
Hi guys,

This is my first attempt of trying to run a tool from within Visual Basic.Net code. I do not know whats wrong as when I tried to run it on ArcMap10, I got this error

Unhandled exception has occured in a component in your application. If you click Continue, the application will ignore this error and attempt to continue

Error HRESULT E _FAIL has been returned from a call to a COM component

I think there's something wrong with my code below. I tried to search for information on the internet but couldnt find any. Appreciate if anyone is kind enough to have a look and correct my code below please. Thank you.

Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click

        ' Initialize the geoprocessor.
        Dim gp As Geoprocessor = New Geoprocessor()
        Dim hillshadeTool As HillShade = New HillShade

        '  Local variables
        Dim kl23_dem As Object = "kl23_dem"
        Dim HillShadeOut As Object = "C:\\Users\\HillShadeTry"

        Dim parameters As IVariantArray = New VarArray

        ' Populate the variant array with parameter values.

        gp.Execute("Hillshade", parameters, Nothing)

    End Sub