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?
أكثر...
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?
أكثر...