Problems w/ MapScript C#

Ian Erickson ierickson at ANALYGIS.COM
Sun Apr 3 23:49:59 EDT 2005


I've successfully built the C# Mapscript assembly, and have successfully
written code that generates an image file to disk.  Everything seems to
work just fine until I make repeated calls to the map.draw() function.
I get the following exception after 3 or 4 calls to the private member
function drawMapImage():

System.NullReferenceException: Object reference not set to an instance
of an object.
   at mapscriptPINVOKE.mapObj_draw(IntPtr jarg1)
   at mapObj.draw()
   at SimpleMap.Form1.drawMapImage()

My drawMapImage() member looks like this:

        private void drawMapImage()
        {
            try
            {
                m_img = m_map.draw();
                m_img.save(@"E:\Web\Data\console.png", m_map);
                Console.WriteLine("Image saved!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:\n" + e);
            }
        }

The contstructor for this form contains the two following lines:

            m_map = new mapObj(@"E:\Web\Data\road.map");
            m_img = m_map.draw();

I've got no idea of where to go from here.  I've tried local definitions
of the m_map and m_img objects and explicitly disposing them.  I've even
forced the System.GC.Collect() method in an attempt to clean any unused
objects up.  Does anyone have a clue as to where to go from here?

--
Ian Erickson
AnalyGIS, LLC



More information about the mapserver-users mailing list