I have been given a point shapefile but it's feature class is null. I haven't seen this before so I'm wondering if the data is bad or if it's something I need to handle with code.

//I was using this to determine if my layer was a point layer, but it's FeatureClass is null
public void isPointsLayer(ILayer layer)
IFeatureLayer fl = layer as IFeatureLayer;
if (fl == null && fl.FeatureClass == null) return false; 
esriGeometryType type = fl.FeatureClass.ShapeType;
if (type == esriGeometryType.esriGeometryPoint) return true;


I guess ILayer.Valid returned false, thanks for the answers.

  • If you used code to create the featurelayer, please post that too. If not cast the featurelayer to IDataLayer then cast IDataLayer.datasetname to IDatasetName, and print out IDatasetName.workspacename.pathname. – Kirk Kuykendall Apr 27 '11 at 22:22
  • Can you see any data on the screen? Is there an exclamation mark in your list of layers? – Ragi Yaser Burhum Apr 28 '11 at 0:35
  • @Ragi iterationx is (bravely) using arcengine without any desktop apps. (I can't remember, but I don't think the arcengine TOC control will show the red exclamation marks, does it?). – Kirk Kuykendall Apr 28 '11 at 14:40
  • @Kirk Ah that makes sense. I havent used the TOC control in 6+ years so I dont remember if it does. The reason I asked is exactly because of I had a hunch that it wasnt pointing to anything, but Petr beat me to it :) – Ragi Yaser Burhum Apr 28 '11 at 14:56
  • @Kirk Kuykendall, I'm not sure, I stopped using the TOC control and programmed my own in with a WPF TreeView, because I'm using dynamic display and setting ILayer max / min visibility breaks the dynamic display engine, and therefore I simulate max / min viz by adding or removing layers when the extent changes, it actually works which is surprising. I wish i had ArcInfo / Editor but my boss won't buy it for me. – patrick Apr 28 '11 at 15:10

The terminology is actually a bit different - a shapefile's feature class is not null, it's the feature layer which has null feature class reference.

This means that the reference to your data (the shapefile) is broken. This can be checked beforehand through ILayer.Valid property.

| improve this answer | |

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.