Select to view content in your preferred language

VS 2010 .NET 3.5 - A reference to FileGDBAPI.dll could not be added

2560
5
10-25-2011 11:44 AM
SeanConnolly
Emerging Contributor
Hello,

I am using Visual Studio 2010 with .NET 3.5 (32 bit)

Without rewriting my application can I use the File Geodatabase API?

I have tried to add the VS2010 and VS2008 API DLL's but I have had no luck.

Any tips would be greatly appreciated.

Thanks.
0 Kudos
5 Replies
LanceShipman
Esri Regular Contributor
File Geodatabase API 1.1 was built with .NET Framework 4.0 and will not work with earlier versions. This is missing from the README file and will be corrected in the next release.
0 Kudos
SimonKaufman
New Contributor
Hi,

I am also getting this error - but I DO have .net framework 4 installed. Any advice, please?
0 Kudos
SeanConnolly
Emerging Contributor
I'm not sure if this is an option for you, but I ended up using an ArcView licence to connect to the GDB. Here is my Code:

            Imports ESRI.ArcGIS.esriSystem
            Imports ESRI.ArcGIS.esriSystem.esriExtensionState

            'Open an ArcView License (To connect to the .GDB)
            Dim init As New AoInitialize()
            If Not init.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView) = esriLicenseStatus.esriLicenseCheckedOut Then
                Return False
            End If

            'Open a Connection to the .GDB
            Dim cn As OleDbConnection = FileGdbConnection(GDB_Path)
            cn.Open()

            'Fill a DataTable will all the information from TABLE_NAME
            Dim cmd As New OleDbCommand("SELECT * FROM TABLE_NAME", cn)


            'Dim cmd As New FileGDBCommand("SELECT * FROM TABLE_NAME", cn)
            Dim dt As New DataTable("TABLE_NAME")
            dt.Load(cmd.ExecuteReader())

            'Close Connections
            cn.Dispose()
            init.Shutdown()



    Public Function FileGdbConnection(ByVal Path As String) As OleDbConnection

        ' Build the connection string.
        Dim fileGdbStringTemplate As String = "Provider=ESRI.GeoDB.OleDB.1;Data Source={0};" & "Extended Properties=workspacetype=esriDataSourcesGDB.FileGDBWorkspaceFactory.1;"
        Dim connectionString As String = String.Format(fileGdbStringTemplate, Path)

        ' Create the connection and return it.
        Dim fileGdbConn As OleDbConnection = New OleDbConnection()
        fileGdbConn.ConnectionString = connectionString

        Return fileGdbConn

    End Function
0 Kudos
LanceShipman
Esri Regular Contributor
You do not need a ArcGIS license of any kind to run code written with the File Geodatabase API.
0 Kudos
LanceShipman
Esri Regular Contributor
Hi,

I am also getting this error - but I DO have .net framework 4 installed. Any advice, please?


Can you post example code that returns this problem. We cannot reproduce this issue.
0 Kudos