Select to view content in your preferred language

Newbie question VB.NET + ArcGISRuntime

2336
3
Jump to solution
03-14-2016 08:59 PM
MarcHillman
Regular Contributor

I'm using MS VB 2015, and I have the Esri.ArcGISRuntime loaded as a reference.
How do I open an existing Shapefile? I just want to extract some data, but having real trouble getting started. Can't seem to find any tutorials for the simple stuff.
TIA

This is my code

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Async Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click

        Dim dialog As New OpenFileDialog()

        With dialog

            .Filter = "Shape|*.shp|All|*.*"

            If DialogResult.OK = .ShowDialog Then

                Dim myShapefileTable As Esri.ArcGISRuntime.Data.ShapefileTable = Await myShapefileTable.OpenAsync(dialog.FileName)

            End If

        End With

    End Sub

End Class

but I get warning "BC42025    Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated."

0 Kudos
1 Solution

Accepted Solutions
MarcHillman
Regular Contributor

Fixed. Bit in red needs to be this.

            Dim myShapefileTable As Esri.ArcGISRuntime.Data.ShapefileTable = Await Esri.ArcGISRuntime.Data.ShapefileTable.OpenAsync(dialog.FileName)

View solution in original post

0 Kudos
3 Replies
AdrianWelsh
MVP Honored Contributor

Hi Marc,

Can you give a little more description on what you are wanting to do? Are you wanting to load a shapefile into an ArcMap session? Are you wanting to just have the shapefile loaded into your code so that you can do stuff with it later?

I believe you have to call the FeatureLayer object in order to grab the shapefile. You're right that there are not many examples online. Take a look at this for some tidbits:

Code Example - FeatureLayerViaShapefile

(scroll to the bottom/middle and click on the  VB.NET area to toggle it off of C#).

Or maybe you need to use the ShapefileWorkspaceFactory object to get the shapefile.

...new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass()

There is an example here:

ArcObjects 10 .NET SDK Help

(scroll to the bottom or middle to get past the C# code)

0 Kudos
MarcHillman
Regular Contributor

I have edited my post to show the code. It uses a fragment of the example you quote. Can't seem to get the OpenAsync method to work.
I just want to extract some shape data and export it as KML. No maps used.

0 Kudos
MarcHillman
Regular Contributor

Fixed. Bit in red needs to be this.

            Dim myShapefileTable As Esri.ArcGISRuntime.Data.ShapefileTable = Await Esri.ArcGISRuntime.Data.ShapefileTable.OpenAsync(dialog.FileName)
0 Kudos