Select to view content in your preferred language

Rebuild Locator with ILocatorWorkspace2

771
1
Jump to solution
03-31-2012 06:46 AM
MeleKoneya
Frequent Contributor
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?     Please let me know if you can assist.

Thanks,

Mele
0 Kudos
1 Solution

Accepted Solutions
MeleKoneya
Frequent Contributor
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

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00250000001w000000.htm%20

View solution in original post

0 Kudos
1 Reply
MeleKoneya
Frequent Contributor
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

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00250000001w000000.htm%20
0 Kudos