4

I'm able to connect to a file geodatabase using an OleDbDataAdapter and read the attribute table just fine - from within visual studio.

However, when I put the code inside a windows service it crashes (no error, just kills the service).

The line it crashes on is commented in the code below (when executing the reader).

    Dim fgdbPath as String = "c:\esridata\myfgdb.gdb"
    Dim tableName as String = "TableXX"
    Dim conn as OleDbConnection = New OleDb.OleDbConnection("Provider=ESRI.GeoDB.OleDB.1;Data Source=" & fgdbPath & ";Extended Properties=WorkspaceType=esriDataSourcesGDB.FileGDBWorkspaceFactory.1;Geometry=WKB")
    Dim reader As OleDbDataReader = Nothing
    Try
        conn.Open()

        Dim cmd As New OleDbCommand("Select top 2 ID, CITY  FROM " & tableName, conn)
        reader = cmd.ExecuteReader() ' crashes here!

I also tried using an OleDbDataAdapter.Fill(DataSet, tableName) but it would crash on this line as well.

The service will run forever as long as it doesn't hit the above line of code. The try/catch block doesn't catch the error either.

If I can't get this to work, I suppose I could use arcobjects and a cursor but that's the last resort.

I'm using ArcGIS 10, .net framework 3.5, vs 2008

2

Looks like their OLE DB provider will not run within a Windows service context. There's a thread over in the ArcGIS Resource Center detailing a similar situation, and they've done additional debugging to confirm that the code will run from a console app and as a scheduled task. You might want to confirm that with your code just to be sure, and then if the behavior persists, I would recommend reporting to ESRI as a bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.