I have a project that repairs broken datasources. One goal of the project is to add the datasource of a featuredataset to repair any broken feature classes. However, so far the only way I've seen to get the FeatureDataSet is through the FeatureClass. However, since these layers are invalid, there is no featureclass.

Normally the parent featuredataset of a featureclass is held in the FeatureClass. So is it accessible anywhere else?

I have already checked the properties in the IProperties interface, but no such luck. I have also tried casting the IFeatureDataset from IDataset, but obviously, that wont' work since I'm using a featureclass to get to the featuredataset that it's from and it's not a featuredataset to begin with.

1 Answer 1


The featuredataset object itself is not available, but it's name is available through the IDataset interface of the layer (not the featureclass). Here is some sample code that gives you the names of the featureclass and the featuredataset of an invalid layer. Or, in fact, any layer.

var doc = new MapDocumentClass();

IMap map = doc.Map[0];
var dataset = map.Layer[0] as IDataset;

var fcn = dataset.FullName as IFeatureClassName; // This will obviously only work for featurelayers
if (fcn.FeatureDatasetName != null)

var dsn = dataset.FullName as IDatasetName;
Console.WriteLine(dsn.WorkspaceName.PathName); // Path of the workspace, unless it's an SDE databset

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.