Beginner - Help !

Topics: Data Access, SharpMap v0.9 / v1.x
Oct 27, 2011 at 2:57 PM

Hello

 

I'm new, but very interested in SharpMap.

 

I'm trying to use SharpMap to View DGN files. I tried to use the compiled version of SharpMap, but it didn't work, and after a lot of downloading and trying, I managed to compile Branch 0.9.5 in package 93673, and get SharpMap.dll and SharpMap.extension.dll
.

 

I tried to adapt some code I found on this sit, but when I try to pen my File, it generates an Exception : TypeInitializationException

 

Here's my code : (the problems appears on the definition of the datasource)

            SharpMap.Map myMap = new SharpMap.Map(new Size(400, 300));
            myMap.Size = new System.Drawing.Size(300, 200); //Set output size

            myMap.MinimumZoom = 100; //Minimum zoom allowed
            myMap.BackColor = Color.White; //Set background
            //myMap.Center = new SharpMap.Geometry.Point(725000, 6180000); //Set center of map

            //Add PostGIS layer:
            SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer("My layer");
            myLayer.DataSource = new SharpMap.Data.Providers.Ogr("Circuit001.dgn");
           
            myLayer.MaxVisible = 40000;
            myMap.Layers.Add(myLayer);

            //Render the map
            ////1st possibility: Set zoom level
            //myMap.Zoom = 1200; //Set zoom level
            //2nd. possibility: Zoom to extents
            myMap.ZoomToExtents();
            System.Drawing.Image imgMap = myMap.GetMap();

 

Can anyone help ?

 

Thanks,

 

Bart

 

 

 



Coordinator
Oct 27, 2011 at 8:59 PM

Have you followed these steps to configure the path to GDAL correctly?

http://sharpmap.codeplex.com/wikipage?title=Configure%20GDAL%20%20OGR%20FWTools%20(as%20of%20revision%2057193)