Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying to use ArcObjects to rebuild locators in an IWorkspace, but enounter 'COMException was unhandled' error when trying to use the 'rebuildlocator' method on ILocatorWorkspace2.

Here is the code I am using:

    private static IWorkspace ws;

    IWorkspaceFactory2 wsf = new SdeWorkspaceFactoryClass();
    ws = wsf.Open(propertySet, 0);    

    private static void RebuildLocators()
        System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"));

        ILocatorManager locManager = (ILocatorManager)obj;
        ILocatorWorkspace2 locWs = (ILocatorWorkspace2)locManager.GetLocatorWorkspace(ws);

        IEnumLocatorName enumlocName = locWs.get_LocatorNames(esriLocatorQuery.esriLocator, "Address");
        ILocatorName locName = enumlocName.Next();
        //IEnumLocator enumloc = locWs.get_Locators(esriLocatorQuery.esriLocator, "Address");
        //ILocator loc = (ILocator)enumloc.Next();

        while (locName != null)
            locWs.RebuildLocator(locName.Name, null);
            locName = (ILocatorName)enumlocName.Next();

I have tried to pass both the ILocator.Name and ILocatorName.Name, but I suspect the problem might be the ITrackCAncel.

Has anyone had success with rebuilding locators with ILocateWorkspace2?

share|improve this question
up vote 2 down vote accepted

After further investigation, this code does work. The problem I was having was trying to rebuild a locator which was moved from ArcSDE 9.x to our Development ArcSDE 10.x database. ArcGIS 9.x Locators must be recreated in 10

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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