MapScript, C#, delete_classObj exception

Tamas Szekeres szekerest at GMAIL.COM
Sun Sep 17 15:53:18 EDT 2006


Johan,

I've tried the code (with minor modifications) but I cannot reproduce
the problem.
The sample project can be downloaded at:
http://members.chello.hu/szekeres.tamas1/Johan.zip

Note: When using the constructors with parent object the newly created
object is added to the parent by default so using insertLayer,
insertClass and insertStyle is not needed at all.

It would be helpful if you could make a simple application that
produces the problem.


Best Regards,

Tamas Szekeres



2006/9/17, Hallgren Johan E <jhhal at wmdata.com>:
> First of all I have read about the single thread requirement so I quite
> sure that is work that way.
>
> First I create a layer:
>
> layerObj oLayerObj = new layerObj(m_MapObj);
> oLayerObj.connectiontype = MS_CONNECTION_TYPE.MS_INLINE;
> oLayerObj.name = strName;
> oLayerObj.type = oMS_LAYER_TYPE;
> oLayerObj.status = mapscript.MS_ON;
> oLayerObj.transform = mapscript.MS_TRUE;
> m_MapObj.insertLayer(oLayerObj, -1);
>
> then I do something like:
>
> // Class
> classObj = new classObj(oLayerObj);
> styleObj oStyleObj = new styleObj(classObj);
> if (iSymbolIndex > 0)
>         oStyleObj.symbol = iSymbolIndex;
> else
>         oStyleObj.symbol = 0;
> if (colorObj != null)
>         oStyleObj.color = colorObj;
> if (outlineColorObj != null)
>         oStyleObj.outlinecolor = outlineColorObj;
> if (iFillInterval > 0)
>         oStyleObj.size = iFillInterval;
> classObj.insertStyle(oStyleObj, -1);
> iClassIndex = oLayerObj.insertClass(classObj, -1);
> // Set layertransparency
> oLayerObj.transparency =
> getTransparency(xmlDoc.SelectSingleNode("/OBJECT/POLYGON"));
>
> at last I do something like (several times):
>
> shapeObj oShapeObj = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POLYGON);
> oShapeObj.add(oLineObj);
> oShapeObj.classindex = iClassIndex;
> oShapeObj.setBounds();
> oLayerObj.addFeature(oShapeObj);
>
> After what you write I have some change to do, but not with new
> shapeObj? I think I have to create a new one for each new object, isn't
> that right?
>
> I hope you understand but to some changes and see what will happened.
>
> Thanks
> Johan
> ___________________________________
>
>
> Johan Hallgren
>
>
> WM-data
> Pelle Bergs backe 3
> Box 1938, 791 19 Falun
> Tel (och mobil): 023-547 46 (int: +46-2354746)
>
> johan.e.hallgren at wmdata.com
> http://www.wmdata.se
>
> -----Original Message-----
> From: Tamas Szekeres [mailto:szekerest at gmail.com]
> Sent: den 14 september 2006 15:06
> To: Hallgren Johan E
> Cc: MAPSERVER-DEV at lists.umn.edu
> Subject: Re: MapScript, C#, delete_classObj exception
>
> Johan,
>
> I guess you've run into the same problem that were identified recently
> and handled for the upcoming 4.10 release. I should see how you create
> the inline objects, but in advance I can say you should avoid
> creating classObj and shapeObj from scratch. These objects are already
> created when you create a layer. You should just use the reference and
> set the properties on that reference. It must be noted that some of
> the interface members (like layerObj.class) will not be settable in
> the future.
> And also make sure you are not passing mapscript objects between
> multiple threads.
>
> Best Regards,
>
> Tamas Szekeres
>
>
> On 9/14/06, Hallgren Johan E <jhhal at wmdata.com> wrote:
> > Hello
> >
> >
> >
> > I use the 4.8.4 release of MapServer and I'm using csharp/Mapscript
> > option. The problem is that I could run a sequence of calls with no
> > problems and I can do it a number of times but suddenly I have
> problems.
> >
> >
> >
> >
> > The special things I do is that:
> >
> > *         I use the same mapObj several times, in the same process,
> for
> > servral requests.
> >
> > *         I create inline features dynamically.
> >
> > *         I create layers for inline features dynamically.
> >
> > *         I create classes for those dynamically.
> >
> >
> >
> > After the image is created, I tries to clean up (restore) the stage to
> > how it was before the request. That where I have problems, in some
> > cases.
> >
> >
> >
> > In my log file I can read:
> >
> >
> >
> > 2006-04-12 20:23:44 mapscript_csharp
> >
> > Object reference not set to an instance of an object.
> >
> >
> >
> >    at mapscriptPINVOKE.delete_classObj(HandleRef jarg1)
> >
> >    at classObj.Dispose()
> >
> >    at classObj.Finalize()
> >
> >
> >
> > It's really all I can say for the moment. After restarting the process
> > it runs thru as it should, no problems with cleaning up.
> >
> >
> >
> > Any clues?
> >
> >
> >
> > /Johan
> >
> >
> > ___________________________________
> >
> >
> > Johan Hallgren
> >
> >
> >
> >
> > WM-data
> >
> > Pelle Bergs backe 3
> >
> > Box 1938, 791 19 Falun
> >
> > Tel (och mobil): 023-547 46 (int: +46-2354746)
> >
> > johan.e.hallgren at wmdata.com
> > <BLOCKED::mailto:johan.e.hallgren at wmdata.com>
> >
> > http://www.wmdata.se
> > <BLOCKED::/exchweb/bin/redir.asp?URL=http://www.wmdata.se/>
> >
> >
> >
> >
> >
>



More information about the mapserver-dev mailing list