Featureclass is null from Featurelayer

Discussion created by dplotsky on May 1, 2014
Latest reply on May 22, 2014 by dplotsky

I am using ArcObjects 10.1 to read an MXD and am trying to export all of the layers inside of it to shapefiles. I am first getting the featureclass from the layer by using:

IFeatureLayerDefinition2 featureDefinition = (IFeatureLayerDefinition2)featureLayer;

IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = featureDefinition.DefinitionExpression;
queryFilter.SubFields = "*";
IFeatureClass featureClass = featureLayer.FeatureClass;

IDataset dataset = (IDataset)featureClass;
IFeatureClassName inFCName = (IFeatureClassName)dataset.FullName;

However sometimes the FeatureClass is null. This doesn't happen in my environment when I'm testing both within and outside of Visual Studio. However once someone else runs the code against the same MXD then the FeatureClass is null. I have checked the MXD they are using and the links to the data are not broken. It is successfully opening the MXD because I am able to extract the symbol information, but it's just not able to read the data.

Can anyone think of any other reason that this might be returning null? Is there something else I should be asking them to look at in their environment for why this is happening? Any help would be greatly appreciated.