OgrProvider not read layer names

Topics: SharpMap Project, SharpMap v2.0
Jul 27, 2012 at 8:24 AM

Hi all,
I have a problem with OgrProvider and S57 reading file. Under VS2010 everything works, but then build gives this error:

AccessViolationException was unhandled
Attempted to read or write protected memory.This is often an indication that other memory is corrupt.

The problem is this segment of code OgrProvider:

public string LayerName {
get {return _ogrLayer.GetLayerDefn (). GetName ();}
set {
     try {
         OgrLayer layer = _ogrDataSource.GetLayerByName (value);
         _ogrLayer = layer;
     }
     catch {}
     }
}

reading the layer name.
The rest of the code is:

 

Ogr provider;
try {
    provider = new Ogr ( fileName );
}
catch ( TypeInitializationException ex ) {}
 
for ( Int32 i = 0; i < provider.NumberOfLayers - 1; i++ ) {
	Ogr prov = new Ogr ( fileName, i );
 
	//name = prov.LayerName;
	if ( !prov.IsFeatureDataLayer )
		continue;
 
#region Layer Name
						
 name = prov.LayerName; here is the error!!!

Please, help my.