I have a MXD file where all layers point to an Oracle Spatial database. Recently our DBA changed the schema name. So now my MXD file has broken links, each time I open it, all my layers have a exclamation mark beside them.

In order to bulk change the new schema name in the MXD file, I've written an .NET ArcObjects application. But since all my layer data links are broken in my MXD, I do not have the capability to get a reference on IFeatureClass from a IFeatureLayer.

I've found on the web that is normal if a IFeatureLayer is broken within the MXD that the IFeatureClass always returns null.

Actually, all MXD's layers point on the schema "A" and now I want them to point on schema "B". How to do that programmatically?

Can you help me to get the good object that should give me access to change the QueryDef of my layers? Here is the code that I've written until now:

         //Exit if no map document is selected
        string sFilePath = openFileDialog1.FileName;
        if (sFilePath == "") return;

        IMapDocument ipMapDoc;
        ipMapDoc = new MapDocumentClass();


        IMap map = ipMapDoc.get_Map(0);

        IEnumLayer layers = map.get_Layers();
        ILayer layer;
        while ((layer = layers.Next()) != null)
            if (layer is IFeatureLayer)
                IFeatureLayer featureLayer = layer as IFeatureLayer;
                IFeatureClass featureClass = featureLayer as IFeatureClass;

                if (featureClass == null) 
                    Console.WriteLine("FeatureClass where FeatureLayer name is " + layer.Name + " is null");


1 Answer 1


I think doing this in ArcObjects is overkill. The 10.2 arcpy module has a host of commands to help fix broken links. They also give several code examples which you can use. I suggest you have a look here before you put any more effort into the ArcObjects route?

  • Yes you're right but I've found no way to replace the prefix schema name in my layer with ArcPy. I've post a question about that. You can reach the question here. Unfortunately, I've received no valuable answer until now. That's why I've decided to try with ArcObjects instead ArcPy.
    – Geo Karta
    Feb 10, 2014 at 18:27
  • I think to change the schema you have to get exclusive schema lock desktop.arcgis.com/en/arcobjects/latest/net/… Jul 3, 2019 at 20:55

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.