[Gdal-dev] unable to initialize OGR datasource using C#

Tamas Szekeres szekerest at gmail.com
Mon Jun 25 18:17:59 EDT 2007


Eduardo,

I think some of the dll-s could not be loaded by your application. I
guess you should strip the '_fw' suffix of some of the dll-s in the
FWTools bin directory if you don't have those dll-s available on you
system. For example try to rename proj_fw.dll to proj.dll and so on.

Best regards,

Tamas Szekeres



2007/6/25, Eduardo Patto Kanegae <eduardo.kanegae at inflor.com.br>:
> Hi,
>
> I´d like to run some C# benchmarks using OGR x ArcObjects but I´m
> getting some errors with OGR.
>
> I´m running VisualStudio.NET 2005 with Windows XP Pro, created a new
> Windows application project,
> added references for gdal_csharp.dll, gdalconst_csharp.dll,
> ogr_csharp.dll and osr_csharp.dll
> and also C:\Program files\FWTools1.3.2\bin as a project reference path.
>
> Then I added " using OSGeo.OGR " at the begining of my form code but
> when I try to run it,
> it fails at the first line: Ogr.RegisterAll();
>
> Ogr.RegisterAll();
> OSGeo.OGR.DataSource oDS = Ogr.Open("D:\\myshapefile.shp", 0);
> if (oDS == null)
> {
>     MessageBox.Show("DataSource open error!");
> }
> else
> {
>     Driver oDrv = oDS.GetDriver();
>     if (oDrv == null)
>     {
>         MessageBox.Show("getDriver error!");
>     }
>     else
>     {
>         MessageBox.Show(oDrv.name);
>     }
> }
>
> What might be wrong?
>
> The error handler only gives me:
>
> System.TypeInitializationException was unhandled
>   Message="The type initializer for 'OSGeo.OGR.Ogr' threw an exception."
>   Source="ogr_csharp"
>   TypeName="OSGeo.OGR.Ogr"
>
> thanks,
>
> Eduardo Patto Kanegae
> Consultor GIS
> Tel: +55(27)2122-0888
> Cel: +55(27)8155-2990
> Fax: +55(27)2122-0861
> eduardo.kanegae at inflor.com.br <mailto:eduardo.kanegae at inflor.com.br>
> www.inflor.com.br <http://www.inflor.com.br>
> _______________________________________________
> 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