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 currently using the LocateFeaturesAlongRoutes tool wrapper for C#/.NET for a custom tool I'm developing for ArcMap 9.3.1. I've been able to run this tool in ArcMap outside of code in a tool with the same files as parameters.

Unfortunately when I put it in code I keep getting null for the IGeoProcessorResult. Is there any reason why I would get a null object for the result instead of just saying it failed? Also, is there anything wrong with the below code?

The relevant block of code is below.

LocateFeaturesAlongRoutes lfar = new LocateFeaturesAlongRoutes();
lfar.in_features = @"C:\GIS_Temp\CONGPROP.mdb\CONGPROP2";
lfar.in_routes = @"C:\GIS_Temp\Routes.mdb\routes";
lfar.route_id_field = "ROUTE_ID";
lfar.out_table = "eventTable.dbf";
lfar.out_event_properties = "ROUTE_ID LINE FMEAS TMEAS";
lfar.in_fields = "NO_FIELDS";

Geoprocessor geoprocessor = new Geoprocessor();
geoprocessor.TemporaryMapLayers = false;
geoprocessor.OverwriteOutput = true;
geoprocessor.AddOutputsToMap = true;
IGeoProcessorResult result = (IGeoProcessorResult) geoprocessor.Execute(lfar, null);

Any suggestions?

share|improve this question
up vote 2 down vote accepted

Turns out that the result will return null if any of the inputs to the tool are not correct. I found the best way when you don't know all of the parameters is to get the Python script from a run of the tool that was successful. This will at least get how the parameters should look, and that can be converted to .NET.

share|improve this answer
+1 Sounds like an acceptable answer to me. Please check the "accept" box. – Kirk Kuykendall Apr 3 '13 at 21:04
Still getting used to this... I guess I didn't have enough confidence to say I answered my own question :) – Daniel Reeves Apr 3 '13 at 21:09

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.