How do you cast an SDE table to IFeatureClassLoad using ArcObjects? I'm getting an error with this attempt below which is not the correct method:

   Dim pSDEFeatWksp As IFeatureWorkspace = workspaceFactory.Open(propertySet, 0)
   Dim table2 As ITable = pSDEFeatWksp.OpenTable("database.LOADER.tablename")

   Dim fclass As IFeatureClass = table2 ' <<< ERROR HERE
   Dim FCLoad As IFeatureClassLoad = fclass
   FCLoad.LoadOnlyMode = False


System.InvalidCastException: Unable to cast COM object of type 'System._ComObject to interface type 'ESRI.ArcGIS.Geodatabase.IFeatureClass'...

I found this example which uses IFeatureClassLoad, however it is not dealing with a SDE.

This question is extending upon a previous question of mine.

Edit SDE table with ArcObjects - continued

Thank you!

  • Is database.LOADER.tablename really a featureclass? – Kirk Kuykendall Aug 17 '11 at 16:00
  • @Kirk Kuykendall, no it is a SDE table. – artwork21 Aug 17 '11 at 16:10
  • Then the cast does not make any sense. You can cast to, say, ITable interface. – Petr Krebs Aug 17 '11 at 16:13
  • Apart from that, load-only mode really makes sense only for featureclasses (and raster catalogs) since its primary purpose is to bypass spatial index updates and rebuild the spatial index at once when data loading is done. – Petr Krebs Aug 17 '11 at 16:14
  • If I'm not mistaken a table can put into load mode using the same interface. Let me check. – George Silva Aug 17 '11 at 16:15

From the IFeatureClassLoad Manual:





As other noticed:

A) you're casting an ITable to IFeatureClass where that ITable is not a IFeatureClass (all feature classes can be casted as ITable, but not the other way around);

B) Only feature classes can be casted to IFeatureClassLoad in ArcSDE; That can only be done in File Geodatabases;

  • George, I find your last sentence confusing. What can only be done in a FGDB? – Regan Sarwas Aug 17 '11 at 23:12

Your Answer

