[gdal-dev] question about ogr

Mateusz Loskot mateusz at loskot.net
Sat Apr 19 10:51:24 EDT 2008

windwxc at sina.com wrote:
>  hi,everyone. i meet a question about org. i use VisualStudio2005 with windows XP and i have copy some ogr dll file to bin of my application project.but when i run my project and throw a error, it fails at the first line: Ogr.RegisterAll(). Error is "The type initializer for 'OSGeo.OGR.Ogr' threw an exception."  I find someone meet same question but his method cannot well run and i still cannot find the reason. The following is my codes and i add "using OSGeo.OGR;".
>  public void GetGeometry(string sqltext)
>         {
>             try
>             {
>                 Ogr.RegisterAll();
>                }
>             catch (Exception e)
>             { MessageBox.Show("regesiter failor:" + e.Message); }
>             //OSGeo.OGR.Geometry myGeom;
>                try
>                {
>                    OSGeo.OGR.DataSource conn = Ogr.Open("PG:host=locatal dbname=stdb user=stuser password=123", 1);
>                    OSGeo.OGR.Layer myLay = conn.ExecuteSQL(sqltext, null, "tt");
>                    conn.Dispose();
>                }
>                catch (Exception e)
>                { MessageBox.Show("open file failor:" + e.Message);
>               }
>                }
> please help me.
> thank you!
>                                                                                                      windsnow

If you don't mind, I'd have two requests:

1. Please, use meaningful subject. It will help people to read your posts
as well as search through the archives.

2. Please DO NOT send your posts in HTML (http://asciiribbon.org/). As 
you can see above, your post is completely unreadable as messed with 
XML/HTML entities.

Thank you!

Mateusz Loskot

More information about the gdal-dev mailing list