polyLine's method Intersect() runtime error with line.lenght = null ?!

hey everyone,
when i started using xtiled it imported the map correctly into xna but after i restarted my computer it began to show this error :
help please , igot a project to submit, thanks.

Judging by the screenshot, this.Lines is null. You may want to check whether this variable is properly initialized. This would have to be the case because in C#, I don’t think this can be null (in C++ it can) and even if this.Lines.Length could be null, that’s not the variable being referenced.

Note that I haven’t used XTiled and that @michael_neel is no longer maintaining it since Microsoft abandoned XNA.

Polyline objects are created from the static method Polyline.FromPoints -
it would be possible to have a null Lines member if you called that method
with no actual points. If it’s possible in TMX to have an empty polyline
tag that would be one cause (or if you edited the file in such a way to
make that happen), another would be if you were creating your own Polyline
objects manually via new and not using the static method to initialize the
object.

Mike

thanks for replying.
i just want to inform that i haven’t modified the any of the original source code in the matter of it’s concept all i did was add a Try Block

to catch this error

and i did that for every line that has Convert.ToInt32() in it.
now my problem lyes in the nullReference of the lines list even though it has worked before it just generates that error randomly, and if i delete all of my object layers and recreate them it works only for a few times then it gives that frustrating error again.help please ,thanks @michael_neel .
ps: i switched to use polygons but that has another set of issues.

If you get uncaught exceptions, you should generally look into how the code could be fixed rather than inserting try/catch just to hide the problem. By not fixing it, you’ve probably caused your polygons to silently turn up empty, which inevitably has lead to further exceptions down the road where polygons are not expected to be empty.

The issue with the code is that it’s using Convert.ToInt32 to parse possibly floating point numbers, like the polygon node positions are. The assumption that these values are whole numbers used to be valid, but it no longer is. Now, you should change that code to call Convert.ToDouble instead, and adjust the variables holding the data accordingly.

These are the kind of things you get from a parsing lib last updated for
tiled 0.8 =)

thanks a lot Mr. @michael_neel apparently swapping
Convert.ToInt32()
with
(int)Convert.ToDouble()
works just fine.