Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm able to connect to an ESRI fgdb 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.

Note: I'm using ArcGis 10, .net framework 3.5, vs 2008

share|improve this question
    
out of curiosity, you have initialized ArcObjects somewhere, right? help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… –  Ragi Yaser Burhum Nov 18 '11 at 16:23
    
yep, I suspected the same thing. I check out a license right before this and use the IFeatureClass and IFeatureWorkspace just to make sure. –  goku_da_master Nov 18 '11 at 19:55
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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