[gdal-dev] Ogr Problem with ReleaseResultSet

Felix Obermaier obe at IVV-AACHEN.DE
Wed Mar 23 12:29:48 EDT 2011


Hello everyone,

I'm using OGR via its csharp bindings and accessing a MapInfo Table (TAB) using OGR's DataSource.ExecuteSQL function. 
The call is somewhat like.

_ogrLayer = _ogrDatasource.ExecuteSQL(
    @"SELECT CAST(OGR_STYLE AS character(255) AS LABEL " +
     "FROM LAYER WHERE OGR_STYLE LIKE 'LABEL%'", null, String.Empty)

_ogrLayer is a class scope variable, and remains assigned throughout the livecycle of the class.

I know that I'm supposed to release this layer calling _ogrDatasource.ReleaseResultSet(_ogrLayer);
but if I do so in the finalizer or an IDisposable.Dispose() function, I -sometimes- get an exception:

System.ApplicationException wurde nicht behandelt.
  Message=Pointer 'hDS' is NULL in 'OGR_DS_ReleaseResultSet'.

  Source=ogr_csharp
  StackTrace:
       bei OSGeo.OGR.DataSource.ReleaseResultSet(Layer layer)
       bei SharpMap.Data.Providers.Ogr.ReleaseOgrLayer()
       bei SharpMap.Data.Providers.Ogr.Dispose(Boolean disposing)
       bei SharpMap.Data.Providers.Ogr.Dispose()
       bei SharpMap.Data.Providers.Ogr.Finalize()
  InnerException:

Am I allowed to call _ogrLayer.SetSpatialPredicate(...) on a layer created with ExecuteSQL(...)?

Thanks in advance
Felix Obermaier

------------------------------------------
 Ingenieurgruppe IVV GmbH & Co. KG
 Dipl.-Ing. Felix Obermaier
 Oppenhoffallee 171
 52066 Aachen

 Telefon: +49 (241) 94691-39
 Telefax: +49 (241) 531622
 eMail: obe at ivv-aachen.de
 Internet: http://www.ivv-aachen.de

 Sitz der Gesellschaft: Aachen
 Amtsgericht Aachen HRA 6212
 GF: Bauassessor Dr.-Ing. Dieter Hölsken
 IVV-Management GmbH
 Amtsgericht Aachen HRB 12543



More information about the gdal-dev mailing list