ArcObjects - How to conver m-points to a polyline?

Discussion created by shaningesri on Dec 26, 2013
Latest reply on Dec 27, 2013 by shaningesri
I am working on an ArcObjects / SOE project.  I need to convert multiple points into a line feature.  Using the approach at, I got a PolylineClass object: poinColl (its PointCount=213).  In the following step, I tried to cast the PolylineClass object as a Polyline like that
             IPointCollection4 pointColl = CreatePolylineByPoints(pointsCollection, point)  // returns  ESRI.ArcGIS.Geometry.PointClass
             IPolyline polyLine = (IPolyline)pointColl;
The polyLine has no value (e.g. XMax=XMin=...=0.0, MMax=MMin=NaN).
Then I turned to an alternative approach that works for IPointCollection rather than IPointCollection4
            IFeatureClass fc = CreateEmptyPolylineFC(fws, "MyPolyline", sr, routeIdFieldName);
            IFeature polylineFeature = fc.CreateFeature();
            // Assign polyline geometry and M-value
            IPointCollection4 pointColl = (IPointCollection4)polylineFeature;     //(IPointCollection)polylineFeature;
I got InvalidVastException - Unable to cast COM object of type 'System._ComObject' to interface  type 'ESRI.ArcGIS.Geometry.IPointCollection4'...
Another alternative I did was to cast IPointCollection4 object as IPointCollection, but also got InvalidCastException.
What's wrong in my code above?  Thanks for help.