How to set a response object with my polylines?

Discussion created by MikeEber on Oct 21, 2013
Latest reply on Oct 21, 2013 by MikeEber
I  have a geo service that seems to finally be working. I have the service setup with a list of Polylines as the returned object. This is what I'm trying to implement but it doesn't work:

 IPointCollection points = new MultipointClass();
 messages.AddMessage(string.Format("Computing distance from origin to target {0}", index));
 Polyline result = distanceComputer.CostPathAsPolyline(points,
     hydrographyRasterDataset) as Polyline;
 IGeometry feature = result as IGeometry;
 messages.AddMessage("Getting new row for output.");
 IFeatureBuffer buffer = outputClass.CreateFeatureBuffer();
 IFeature polyline = (IFeature) buffer;
 messages.AddMessage("adding shape");
 polyline.Shape = feature;
 messages.AddMessage("adding object");
 polyline.set_Value(polyline.Fields.FindField("SHAPE"), result);
 messages.AddMessage("adding length");
 polyline.set_Value(polyline.Fields.FindField("SHAPE_Length"), ((IPolyline)result).Length);
 messages.AddMessage("Commiting to output");

When I try setting the value for "SHAPE" I get an exception and the message is:

This spatial reference object cannot be defined from the available information
So how exactly to I set the polyline in the return object (basically adding rows of Polylines to the OutputFeatureSet) so that it does not blow up?