Attribute table

Jul 7, 2014 at 4:04 PM
I try to create a basic GIS application with DotSpatial. One thing i want to add is a button to the attribute table of the selected layer. my layout is the basic one with the SpatialToolStrip, Map, Legend and SpatialStatusSrip.
Everything seems to work just fine when the Shapefiles are point or line, But, when i load a polygon shapefile and click the show attribute table button, my app crashes.
The same goes when i create new app and adding a button with this code:
Public Function FeatureLayerType(ByVal dsMap As DotSpatial.Controls.Map, ByVal layerindex As Integer) As String

            If Not TryCast(dsMap.Layers(layerindex), MapPointLayer) Is Nothing Then
                FeatureLayerType = "Point" 'Point Layer
            ElseIf Not TryCast(dsMap.Layers(layerindex), MapLineLayer) Is Nothing Then
                FeatureLayerType = "PolyLine"
            ElseIf Not TryCast(dsMap.Layers(layerindex), MapPolygonLayer) Is Nothing Then
                FeatureLayerType = "PolyGon"
                FeatureLayerType = "NonFeatureLayer"
            End If
            Return FeatureLayerType
        End Function

Private Sub ToolStripButtonTabelweergave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonTabelweergave.Click
            Dim ActPolyLayer As MapPolygonLayer = Nothing
            Dim ActLineLayer As MapLineLayer = Nothing
            Dim ActPointLayer As MapPointLayer = Nothing

            Map1.FunctionMode = FunctionMode.None

            If Map1.Layers.Count > 0 Then
                For i = 0 To Map1.Layers.Count - 1
                    If Map1.Layers(i).IsSelected = True Then
                        If FeatureLayerType(Map1, i) = "PolyGon" Then
                            ActPolyLayer = CType(Map1.Layers(i), MapPolygonLayer)
                        End If
                        If FeatureLayerType(Map1, i) = "PolyLine" Then
                            ActLineLayer = CType(Map1.Layers(i), MapLineLayer)
                        End If
                        If FeatureLayerType(Map1, i) = "Point" Then
                            ActPointLayer = CType(Map1.Layers(i), MapPointLayer)
                        End If

                    End If
            End If
        End Sub
Please any help on why the app crashes only when i want to view the attribute table of a polygon shapefile?
Jul 7, 2014 at 4:27 PM
Hi, what error you are receiving? Usually attribute table works fine with polygon shapefiles too.
Also, try to open your file and view attribute table using DemoMap application.
Jul 7, 2014 at 8:40 PM
Edited Jul 7, 2014 at 8:41 PM
Thx for the reply,

I cant run the DemoMap application, when i download the, I unblock it and extract it. Then i run the DemoMap.exe. I get an error:
"__skipping extension DotSpatial.Plugins.DockManager, Version=,
Culture=neutral, PublicKeyToken=null. Could not load file or assembly
'DotSpatial.Controls, Version=,Culture=neutral,
PublicKeyToken=4d9e49339a7d240c' or one of its dependencies. The system
cannot find the file specified."

There I have only one option to press OK. After that i get the same error for DotSpatial.Plugins.Measure, MenuBar, Ribbon, TableEditor and after that I get e new error:
"A IDockManager extension must be included because a UI plugin was found. See http//"

Here i get the same error but starting with A IHeaderControl, and after that an empty form with the DemoMap logo. So I cant se if the attribute table open in the DemoMap :(

Now In my Application as I said when I load a point or a line type shp everything is perfect. but when i load a polygon and try to view the attribute table i get this:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred in DotSpatial.Symbology.Forms.dll

_Additional information: Index was outside the bounds of the array."

I dont know what to do or how to fix this, so please help me!
Thank you in advance :D
Jul 8, 2014 at 7:55 AM
DemoMap should work - it seems that you are doing something wrong. Try to extract it again to a new folder.
Also, please share your shape file - i'll try to open it too.
Jul 8, 2014 at 9:11 AM
Edited Jul 8, 2014 at 9:13 AM
I tried to re-extract the, I tried to download and extract it too. Then i tried to open it as admin or with compatibility mode windows 7 (because i have windows 8), finally the only way to open demoMap is by moving every plugin (from the folders App extension, Mono extension, plugins and windows extensions) to the main folder where the demomap.exe is. There when i load a new shapefile (only polygon) and i press the attribute table button, i can see it but i get an error too (and if i press ok to the error then everything works fine) the error is "Index was outside the bounds of the array." thanks for the help!
p.s. the file is one polygon shapefile (the error is here with every single one polygon shapefile i load)
Jul 8, 2014 at 9:19 AM
Ok, share your shape file. i'll try to reproduce this error at my side.
Jul 8, 2014 at 9:31 AM
Edited Jul 8, 2014 at 9:33 AM
here is the file.

p.s. you have to click the yield 2012.shp at the top of the page
Jul 8, 2014 at 9:42 AM
This is a not enough. Where is .dbf file?
Jul 8, 2014 at 9:48 AM
... and the index file (.shx)
Jul 8, 2014 at 11:55 AM
here it comes!

i put everything in there. The funny part is that i tryied the same folder in an other computer and everything works perfect. But when i load my application 2 things happen both in my computer and in a second one. first i dont get all the keys in the SpatialToolStrip. (the identify, attribute table and zoom in - out are missing) second thing is that when i try to view the attribute table from a polygon shapefile i get the same error (in both the computers)
Jul 8, 2014 at 12:55 PM
I've reproduced IndexOutOfRangeException at my computer. It raised because your data a bit incorrect: .shp contains 348 shapes, but .dbf contains 400 records. So when AttributeTable trying to show all 400 records, it also expect that there are 400 shapes, and respectively it fails on 349-400 records. I'm not sure that DotSpatial should take care about this - by default number of shapes and dbf records must be the same.
Marked as answer by mogikanin on 7/8/2014 at 9:00 PM
Jul 8, 2014 at 9:55 PM
Thank you for the help! I finally solve the issue :D