Select to view content in your preferred language

Featureclass is null from Featurelayer

852
3
05-01-2014 09:21 AM
DerrickPlotsky
Deactivated User
Hello,

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.
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
Where is the data for those layers located?  If it's on a server, make sure those users have permissions to access the data location.  If the data is local but is in a location created by you, make sure other users can see that location (Windows sometimes hides things you create from other users on the machine, depending on how you have permissions set up).  Another thing to try is to have the other users create a folder connection in ArcCatalog to the folder where the data is located.  I've seen that clear things up in past versions.
0 Kudos
elioelias
Deactivated User
it usually happens when the data source of that feature layer is not valid (wrong password, no longer valid instance, etc)
0 Kudos
DerrickPlotsky
Deactivated User
Unfortunately, I do not think it is because of the data source not being valid. I had the user create a brand new file geodatabase, with a brand new feature class inside of it with a few points. This also came back null.

The real tricky thing for me was that I created a python script to run through the mxd doing the export as well, and that worked just fine, it exported everything to shapefiles, but yet still when trying to access via ArcObjects it comes back null.

I am well and truly stumped.
0 Kudos