[Gdal-dev] GDAL with VB.net (VS 2005 Express)

Tamas Szekeres szekerest at gmail.com
Tue Mar 27 11:09:41 EDT 2007


Milo,

You should also have [FWTools dir]\bin available in your PATH. Or
alternatively copy *.dll from this directory into your application
directory.

It should also be noted that there were some changes in the namespace
names since the latest FWTools release so you will have to take care
of it when upgrading to the next release.

Best regards,

Tamas



2007/3/27, Milo van der Linden <milo at 3dsite.nl>:
>
>  Dear Tamas,
>
>  Thank you for the response! I did as you described. Downloaded FWtools and
> added a reference to ogr_csharp to my project.
>
>  I then copied a small piece of code from one of the csharp samples and
> translated it to VB.net
>
>  In the start of my module I added the line:
>  Imports OGR
>
>  And then in my test-routine, I created the following:
>
>  '/*
> --------------------------------------------------------------------
> */
>  '/*      Initialize srs
>               */
>  '/*
> --------------------------------------------------------------------
> */
>                          Dim src As SpatialReference
>                          src = New SpatialReference("")
>                          src.ImportFromProj4("+proj=latlong +datum=WGS84
> +no_defs")
>                          Debug.Print("SOURCE IsGeographic:" +
> src.IsGeographic() + " IsProjected:" + src.IsProjected())
>                          Dim dst As SpatialReference
>                          dst = New SpatialReference("")
>                          dst.ImportFromProj4("+proj=somerc
> +lat_0=47.14439372222222 +lon_0=19.04857177777778 +x_0=650000 +y_0=200000
> +ellps=GRS67 +units=m +no_defs")
>                          Debug.Print("DEST IsGeographic:" +
> dst.IsGeographic() + " IsProjected:" + dst.IsProjected())
>  '/*
> --------------------------------------------------------------------
> */
>  '/*      making the transform
>               */
>  '/*
> --------------------------------------------------------------------
> */
>                          Dim ct As CoordinateTransformation = New
> CoordinateTransformation(src, dst)
>                          Dim p(3) As Double
>                          p(0) = 19
>                          p(1) = 47
>                          p(2) = 0
>                          ct.TransformPoint(p)
>                          Debug.Print("x:" + p(0) + " y:" + p(1) + " z:" +
> p(2))
>                          ct.TransformPoint(p, 19.2, 47.5, 0)
>                          Console.WriteLine("x:" + p(0) + " y:" + p(1) + "
> z:" + p(2))
>
>  At design time, VB.net has no errors or warnings, but when I run the
> application in Debug mode it halts on the line stating:
>
>                          src = New SpatialReference("")
>
>  The message I get is:
>                          The type initializer for 'OGR.osrPINVOKE' threw an
> exception.
>
>
>  Anyone had this before? Can It be that the OGR_csharp cannot find my proj
> files or something?
>
>  Kind regards,
>
>  Milo van der Linden
>



More information about the Gdal-dev mailing list