I�??m trying to find a geodesic buffered region for a given polyline in a WGS_1984_UTM_Zone_52N coordinate system. However, When I try to get a buffered polygon for this, the program shows AccessViolationException for �??Attempted to read or write protected memory. This is often an indication that other memory is corrupt�?�. Below is what I tried: public void DrawBuffer() { ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = axMapControl1.ActiveView.ScreenDisplay; IElement pInptLine = new LineElementClass(); object missing = Type.Missing; IFillShapeElement pElem = new CircleElementClass(); ISimpleFillSymbol sysm = new SimpleFillSymbol(); sysm.Style = esriSimpleFillStyle.esriSFSDiagonalCross; sysm.Outline.Width = 20; //Get the IRGBColor interface IRgbColor color = new RgbColorClass(); //Set the color properties color.Red = 255; color.Green = 0; color.Blue = 0; color.Transparency = 255; sysm.Color = color; sysm.Outline.Color = color; pElem.Symbol = sysm; ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass(); simpleLineSymbol.Color = color; ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast. ESRI.ArcGIS.Display.IRubberBand2 rubberBand = new ESRI.ArcGIS.Display.RubberLineClass(); ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); screenDisplay.SetSymbol(symbol); screenDisplay.DrawPolyline(geometry); screenDisplay.FinishDrawing(); //Start Buffering IConstructMultipoint myMultiPoint = new MultipointClass(); myMultiPoint.ConstructDivideLength(geometry as ICurve, 10000); IGeometryCollection geometryBag = new GeometryBagClass(); IGeometryCollection Rslt = new GeometryBagClass(); IPointCollection pointCollection = myMultiPoint as IPointCollection; object Missing = Type.Missing; for(int i = 0; i<pointCollection.PointCount ; i++ ) { geometryBag.AddGeometry(pointCollection.get_Point(i), ref Missing, ref Missing); } IGeometryBag enumGeometry = geometryBag as IGeometryBag; IBufferConstruction ipBufCon = new BufferConstruction(); IBufferConstructionProperties2 ipBufConProp = (IBufferConstructionProperties2)ipBufCon; ipBufConProp.UseGeodesicBuffering = true; ipBufConProp.UnionOverlappingBuffers = true; ipBufCon.ConstructBuffers((IEnumGeometry)enumGeometry, 500.0 * 1000.0, Rslt); IPolygon bufrPolygon = Rslt.get_Geometry(0) as IPolygon; //Fill the BufrPolygon IElement iElem = pElem as IElement; iElem.Geometry = bufrPolygon as IGeometry; IFillShapeElement pElemFillShp = pElem as IFillShapeElement; //Add the result as an element of the map pElemFillShp.Symbol = sysm; axMapControl1.ActiveView.GraphicsContainer.AddElement(pElemFillShp as IElement, 0); } Whenever I turned off the UseGeodesicBuffering, the program works fine. But when the property is true, the crash occurs. I�??m trying to find out the problem & debug the code, and still need some help. Any ideas why this code crashes or some working code example with UseGeodesicBuffering = true would be most grateful. Thank you in advance.
... View more