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:

Remarks IFeatureClassLoad is an optional interface supported by feature classes in ArcSDE and feature classes and tables in File Geodatabase. It improves performance of data loading.

With ArcSDE, putting a feature class in load-only mode disables updating of the spatial index while data is loading. In a File Geodatabase, putting a feature class or table in load-only mode disables updating of spatial and attribute indexes while data is loading. Taking the feature class or table out of load-only mode rebuilds the indexes.

While a feature class or table is in load-only mode, other applications cannot work with the data. A feature class or table should be placed in load-only mode only after acquiring an exclusive schema lock on the feature class via the ISchemaLock interface.

The dataset extent reported by the IGeoDataset::Extent property is recalculated when a feature class is removed from LoadOnlyMode to reflect the data present in the feature class.

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

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.