AccessViolationException when calling Ogr ExecuteIntersectionQuery

Topics: Data Access, SharpMap v0.9 / v1.x
Feb 13, 2012 at 9:04 AM

Hi All,

I am trying to track down the cause of a strange problem...

When I try to call the “ExecuteIntersectionQuery” method of the Ogr provider for a MapInfo vector layer from a TAB file (i.e. DAT, MAP, ID, TAB files) using either the BoundingBox or Polygon arguments I get an AccessViolationException, but here is the strange part... I only get this error when I run the compiled EXE. I don’t get the error if run the code in VS2010.

At first I thought I might be doing something wrong (still a possibility), but I have been able to reproduce the problem using the “WinFormsSample.VS2010” project with a slight modification.

Insert the following code block into the “OrgSample.cs” file after just before “//Set up a river layer” (approx line 167) 

So it reads...

//=== Start AccessViolationException Test Block ===

SharpMap.Data.FeatureDataSet lFeatureDataSet = new SharpMap.Data.FeatureDataSet();

layCountries.ExecuteIntersectionQuery(layCountries.Envelope, lFeatureDataSet);

SharpMap.Data.FeatureDataTable lFeatureDataTable = lFeatureDataSet.Tables[0];

SharpMap.Data.FeatureDataRow lFeatureDataRow = (SharpMap.Data.FeatureDataRow)lFeatureDataTable.Rows[0];

SharpMap.Geometries.Geometry lGeometry = lFeatureDataRow.Geometry;


//=== End AccessViolationException Test Block ===

//Set up a river layer


Set the “WinFormsSample.VS2010” project as the “Startup Project” and run within VS2010 IDE. Click the top “Start...” button to select “Different kind of layers which [MapBox]”. Then click option button “OGR – MapInfo”. This will work OK and display a MessageBox dialog showing the WKT of the Geometry with the MapInfo layer for the first FeatureDataRow, but run the “WinFormSamples.exe” from the “bin” directory and the AccessViolationException occurs.

Any suggestions?

Feb 13, 2012 at 10:43 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.