[Gdal-dev] GDAL C# bindings exception: Attempted to read or write protected memory

Tamas Szekeres szekerest at gmail.com
Tue Apr 24 06:36:51 EDT 2007


Ben,

If you would like to use the gdal1.4 branch as the gdal core and only
aware of the C# interface of the SWIG bindings, then checkout:
http://svn.osgeo.org/gdal/branches/1.4/gdal/
and replace the the swig directory with the files from the SVN trunk.

Then you can compile gdal and gdal C# as usual.

Best regards,

Tamas


2007/4/24, Ben Greene <bgreene at rapidmap.com.au>:
> Tamas,
>
> Would the SVN trunk be considered stable enough to release with a commercial product?  If it's probably not a good idea, is there currently a target date for a stable release based on this new code?
>
> Thanks
>
>         -----Original Message-----
>         From: Tamas Szekeres [mailto:szekerest at gmail.com]
>         Sent: Mon 4/23/2007 8:29 PM
>         To: Ben Greene
>         Cc: gdal-dev at lists.maptools.org
>         Subject: Re: [Gdal-dev] GDAL C# bindings exception: Attempted to read or write protected memory
>
>
>
>         Ben,
>
>         I would suggest to start with the latest SVN trunk. There were some
>         fundamental changes compared with the current stable branch. It might
>         be more difficult to make this transition later. For more information
>         see:
>
>         http://trac.osgeo.org/gdal/wiki/GdalOgrCsharpVersions
>         http://trac.osgeo.org/gdal/wiki/GdalOgrInCsharp
>
>         Best regards,
>
>         Tamas
>
>
>
>         2007/4/23, Ben Greene <bgreene at rapidmap.com.au>:
>         > Hi,
>         >
>         > I had a problem with the GDAL C# bindings freezing a little while ago, and Tamas managed to find the problem (I was passing in a two-element array instead of a three element for the return value).  However, now I'm having a different issue.
>         >
>         > I'm working with 1.4.1 binaries compiled myself according to the instructions on this site (I can't find the most recent binaries in the FWTools distribution).  When I run the code below, I get a System.AccessViolationException:Attempted to read or write protected memory exception on the line:
>         > transform.TransformPoint(point, px, py, 0.0)
>         >
>         > It appears that the exception is thrown from this line:
>         > public void TransformPoint(double[] argout, double x, double y, double z) {
>         >
>         > osrPINVOKE.CoordinateTransformation_TransformPoint__SWIG_1(swigCPtr, argout, x, y, z);
>         >
>         > }
>         >
>         > The test image I'm using is:
>         >
>         > o41078a5.tif
>         > from
>         > http://dl.maptools.org/dl/geotiff/samples/usgs/
>         >
>         > Here is the VB.Net code I'm using (in VS 2005):
>         >
>         > Imports GDAL
>         >
>         > Imports OGR
>         >
>         > Public Class GeoTiffReader
>         >
>         > Private Shared image As Dataset
>         >
>         > Public Shared Function GetGeoReference(ByVal Filename As String) As GeoReference
>         >
>         > If Not (Filename Is Nothing) Then
>         >
>         > 'Return Nothing
>         >
>         > 'if uncommented, the code will not crash
>         >
>         > End If
>         >
>         > GDAL.gdal.AllRegister()
>         >
>         > image = GDAL.gdal.Open(Filename, 0)
>         >
>         > If (image Is Nothing) Then
>         >
>         > Return Nothing
>         >
>         > End If
>         >
>         > Dim gr(6) As Double
>         >
>         > image.GetGeoTransform(gr)
>         >
>         > Dim topLeft() As Double = TransformWGS84(gr(0), gr(3))
>         >
>         > Dim bottomRight() As Double = TransformWGS84(gr(0) + gr(1) * image.RasterXSize, gr(3) + gr(5) * image.RasterXSize)
>         >
>         > If (topLeft.Length = 2 And bottomRight.Length = 2) Then
>         >
>         > Return New GeoReference(topLeft(0), topLeft(1), bottomRight(0), bottomRight(1))
>         >
>         > Else
>         >
>         > Return Nothing
>         >
>         > End If
>         >
>         > image.Dispose()
>         >
>         > End Function
>         >
>         > Public Shared Function TransformWGS84(ByVal px As Double, ByVal py As Double) As Double()
>         >
>         > Dim point() As Double
>         >
>         > point = New Double() {0.0, 0.0, 0.0}
>         >
>         > Dim srWGS84 As New SpatialReference("")
>         >
>         > srWGS84.SetWellKnownGeogCS("WGS84")
>         >
>         > If (image.GetProjection() = "") Then
>         >
>         > Return New Double() {}
>         >
>         > End If
>         >
>         > Dim srCurrent As New SpatialReference(image.GetProjection())
>         >
>         > Dim transform As New CoordinateTransformation(srCurrent, srWGS84)
>         >
>         > If (transform Is Nothing) Then
>         >
>         > Return New Double() {}
>         >
>         > End If
>         >
>         > Try
>         >
>         > transform.TransformPoint(point, px, py, 0.0)
>         >
>         > Catch
>         >
>         > Return New Double() {}
>         >
>         > End Try
>         >
>         > Return point
>         >
>         > End Function
>         >
>         > End Class
>         >
>         >
>         > _______________________________________________
>         > Gdal-dev mailing list
>         > Gdal-dev at lists.maptools.org
>         > http://lists.maptools.org/mailman/listinfo/gdal-dev
>         >
>
>
>



More information about the Gdal-dev mailing list