Hi, I'm having exactly the same problem, clip works fine with Feature Classes, but not with Feature Layers which I need to use as they have a selection. Did you ever solve this? I've tried alot of the solutions to this I could find with Google from the old forums, and the problem is always the invalid parameter of the feature layer. 2 of the mehtods I've tried are copied in below.
Dim GP As ESRI.ArcGIS.Geoprocessing.IGeoProcessor
GP = New ESRI.ArcGIS.Geoprocessing.GeoProcessor
Dim Parameters As IVariantArray
Parameters = New VarArray
Parameters.Add(pClipFtrLyr)
Parameters.Add(pInLayer)
Parameters.Add(pOutFtrClsNmDS.WorkspaceName.PathName & "\" & pOutFtrClsNmDS.Name)
Try
GP.Execute("Clip_analysis", Parameters, Nothing)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Doh!")
End Try
second method tested:
Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
GP.OverwriteOutput = True
GP.AddOutputsToMap = False
Dim pClipTool As ESRI.ArcGIS.AnalysisTools.Clip = New ESRI.ArcGIS.AnalysisTools.Clip
pClipTool.in_features = pClipFtrLyr
pClipTool.clip_features = pInLayer
pClipTool.out_feature_class = pOutFtrClsNmDS.WorkspaceName.PathName & "\" & pOutFtrClsNmDS.Name
Dim pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult
pResult = CType(GP.Execute(pClipTool, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)
If Not pResult Is Nothing Then
Dim GPError As String = ""
Dim ErrCount As Integer
If GP.MessageCount > 0 Then
For ErrCount = 0 To GP.MessageCount - 1
GPError += (GP.GetMessage(ErrCount)) & vbNewLine
Next
MsgBox(GPError, MsgBoxStyle.OkOnly, "Failed")
End If
Else
Dim GPError As String = Nothing
Dim ErrCount As Integer
If GP.MessageCount > 0 Then
For ErrCount = 0 To GP.MessageCount - 1
GPError += (GP.GetMessage(ErrCount)) & vbNewLine
Next
MsgBox(GPError, MsgBoxStyle.OkOnly, "Failed")
End If
End If