Select to view content in your preferred language

arcobjects run "intersect" gp tool, get "Object reference not set to an instance of an object" error

2271
2
Jump to solution
10-13-2014 11:55 PM
LiYao
by
New Contributor III

Dear all,

I am using vb.net arcobjects to run "intersect" GeoProcessing tool, but get "Object reference not set to an instance of an object" error.

My code is as follows:

            Dim objGP As IGeoProcessor = New GeoProcessor

            Dim InputLayer = "dev_db.DBO.Segment;dev_db.DBO.LINE_1"

            Dim output = "D:\dev\Seg_line_intersect"

            objGP.OverwriteOutput = True

            Dim objParameters = New VarArray

            objParameters.Add(InputLayer)

            objParameters.Add(output)

            Dim objResult As IGeoProcessorResult = objGP.Execute("Intersect_Analysis", objParameters, Nothing)

The error is:

gperrrrrrrrrrrrrrrrr.jpg

There are selected features in the segment layer.

I am using arcmap 10.2.2.

I failed to find what's wrong with my code, please kindly advice on it, thanks a lot.

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Li Yao,

First reason for this error would be the path for input layers. I see that you are using the layers from SDE, but not specifying the SDE properties or geodatabase location. So add the sde file location as the default workspace as follows:

objGP.SetEnvironmentValue("workspace", "C:\temp\SQLDirect.sde")

Second reason would be the output path. If this is a geodatabase then the path should be "D:\dev.gdb\Seg_line_intersect". If this is a shapefile then the path should be "D:\dev\Seg_line_intersect.shp".

Try this out and let me know if this helps.

Thanks,

Mohini

View solution in original post

2 Replies
by Anonymous User
Not applicable

Hi Li Yao,

First reason for this error would be the path for input layers. I see that you are using the layers from SDE, but not specifying the SDE properties or geodatabase location. So add the sde file location as the default workspace as follows:

objGP.SetEnvironmentValue("workspace", "C:\temp\SQLDirect.sde")

Second reason would be the output path. If this is a geodatabase then the path should be "D:\dev.gdb\Seg_line_intersect". If this is a shapefile then the path should be "D:\dev\Seg_line_intersect.shp".

Try this out and let me know if this helps.

Thanks,

Mohini

LiYao
by
New Contributor III

Hi Mohini,

Thanks for the reply, I have already solved the issue.

0 Kudos