descalera

Error when creating a Locator

Discussion created by descalera on Mar 5, 2012
I have a problem when trying to create a locator, I get the error: The table was not found. [NewLocator_lox].

do I need to add something to my GDB in order to be able to create a Locator?

This is the code I'm using right now, pretty much the same as the arcgis example of creating locators

ILocatorManager2 locatorManager = new LocatorManagerClass();
                ILocatorWorkspace locatorWorkspace = locatorManager.GetLocatorWorkspaceFromPath("");
                ILocatorStyle locatorStyle = locatorWorkspace.GetLocatorStyle("General - City State Country");
               
                ILayer layer = mapControl.ActiveView.FocusMap.get_Layer(2); //

                if (layer is IFeatureLayer)
                {
                    IFeatureLayer featureLayer = layer as IFeatureLayer;
                    if (featureLayer != null)
                    {
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass != null)
                        {
                            IDataset dataset = featureClass as IDataset;

                            IReferenceDataTables referenceDataTables = locatorStyle as IReferenceDataTables;
                            IEnumReferenceDataTable enumReferenceDataTable = referenceDataTables.Tables;
                            enumReferenceDataTable.Reset();

                            IReferenceDataTable referenceDataTable = enumReferenceDataTable.Next();
                            IReferenceDataTableEdit referenceDataTableEdit = referenceDataTable as IReferenceDataTableEdit;
                            IName name = dataset.FullName;
                            referenceDataTableEdit.Name_2 = name as ITableName;

                            if (referenceDataTables.HasEnoughInfo)
                            {
                                locatorWorkspace = locatorManager.GetLocatorWorkspace(dataset.Workspace);
                                ILocator locator = locatorWorkspace.AddLocator("NewLocator", locatorStyle as ILocator, "", null); // THE ERROR OCCURS HERE!!!
                            }
                        }
                    }
                }

any help will be appreciated

Thanks.

David E.

Outcomes