This project is read-only.

error: "Object reference not set to an instance of an object"

Oct 8, 2010 at 6:16 AM

I was testing that multilinestring sample code and modified it a bit and added a few lines of code to show it in the map window:

 fs.SaveAs("C:\Temp\linetest.shp", True)
Dim myLayer As IMapFeatureLayer
myLayer = Map1.Layers.Add(fs)
myLayer.LegendText = "Line Test"

This works OK, but when I added a code to read CSV data in, I got above mentioned error message and the debugger points to "fs.SaveAs..." line. CSV data comes in OK, but it seems that featureset triggers it. Troubleshooting tips show suggestion: "Use the "new" keyword to created an object instance." I declared "Dim fs As New FeatureSet()" which worked OK before adding that CSV data reading code. Any idea what I could try?

Oct 8, 2010 at 9:39 PM

I did some further debugging and noticed that when I changed this loop:

For ii As Integer = 0 To 39

' code here...

Next

to this:

 Do Until EOF(FileID)

' code here...

Loop

then the error appears. I have no idea why it happens, but I hope somebody does.

Oct 8, 2010 at 9:59 PM
Extra line at the end of the file?

check to see if the line is null, if so, next

On Fri, Oct 8, 2010 at 1:39 PM, anziga <notifications@codeplex.com> wrote:

From: anziga

I did some further debugging and noticed that when I changed this loop:

For ii As Integer = 0 To 39

' code here...

Next

to this:

 Do Until EOF(FileID)

' code here...

Loop

then the error appears. I have no idea why it happens, but I hope somebody does.

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Oct 8, 2010 at 11:01 PM

Files are OK, there are no extra lines. I did a test with a point CVS file using almost same code and that worked well. I think I'll put the code to write the same data to a text file what goes into featureset, maybe that shows something.

Oct 8, 2010 at 11:39 PM

The code writes the data OK, same as with the point file. Only when the line "fs.SaveAs("C:\Temp\linetest.shp", True)" suppose to execute, the error appears. FeatureSet has some problems, is there a way to open it and study how the data looks like?

Oct 9, 2010 at 1:17 AM

readline, log, add to features, save, lather rinse repeat until crash. File issue

(sorry, I'm not fully familiar with the code)

Oct 9, 2010 at 8:19 AM
Edited Oct 9, 2010 at 8:20 AM

I checked the number of featureset's datatable's rows and that match the number of breaklines(polylines) in CSV files, so that part looks OK. I still would like to be able to "open" that featureset somehow to really see, if that is OK. I have tried various ways, but no luck so far.

Oct 9, 2010 at 9:26 AM
Edited Oct 10, 2010 at 12:43 AM

I tried to read the featureset by using "fs.DataTable.WriteXml(myXML)" to write the info to xml file, but I got "Cannot serialize the DataTable. DataTable name is not set." error message. When I tried to check the datatable name, it returned empty. Not sure if this is the way to go?

I set the name for the datatable and managed to write it into xml file, and now I can see the problem... beside the datatable's name beginning of each row, there is no  data. I need to break down the code and investigate where I made a mistake.

That wasn't it... I can actually write data into datatable, but not sure what triggers that error. Back to the drawing board....

 

 

Oct 10, 2010 at 6:52 AM
Edited Oct 17, 2010 at 1:22 AM

The problem is that I have various polylines in the CSV file, some has only a few points and some even hundreds. If I have only one polyline in the file, I can programmatically check the number of coordinates in it and use "Dim coord As Coordinate() = New Coordinate(intNoCoords) {}" and this works OK, but I have no idea if this could be done differently. The format I'm using in CSV is:

<lineID, Y, X, Z>  lineID is unique int number for each line.

So I can now read linestring into the map line by line, but it is not convenient to do, if there's a huge number of lines. Anyone has an idea how to do this logically?

Finally managed to get it work....