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?


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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