ThinkGeo.com    |     Documentation    |     Premium Support

AccessViolationException in GetBoudningBox() call

Hi,


I am trying to display a shape file which is in geographic coordinate system to UTM. I am getting the "AccessViolationException" when trying to get the bounding box. Here is my code. Can someone help me where I am dong wrong?



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


winformsMap1.MapUnit =



GeographyUnit.Meter;Proj4Projection proj = new Proj4Projection(4326, 23030);

 


austinLayer.RequireIndex =


austinLayer.Open();


ShapeFileFeatureLayer austinLayer = new ShapeFileFeatureLayer(strFilename);false;

austinLayer.FeatureSource.Projection = proj;


austinLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle =


LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Red, 2, true);

austinLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel =


ApplyUntilZoomLevel.Level20;

winformsMap1.StaticOverlay.Layers.Add(austinLayer);



winformsMap1.CurrentExtent = austinLayer.FeatureSource.GetBoundingBox(); //Getting Exception here



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Thank you,


Suresh



 



Suresh, 
  
 You need to open the projection before getting the boundingbox as following. 
  
 austinLayer.FeatureSource.Projection.Open() 
  
 Ben.

Thanks Ben. It worked.

Great! Just let us know if we can make your coding easier.