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:
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.
Solved! Go to Solution.
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
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
Hi Mohini,
Thanks for the reply, I have already solved the issue.