Exception with ArcObjects 10 Address Standardizer

Discussion created by positron on Mar 2, 2011

I'm having trouble with the new standardizer. The following code produces an exception on the second call to ParseAddressSample(). Any ideas ?

using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.DataSourcesGDB;

using ESRI.ArcGIS.Location;

namespace PopulateRC
    class Program

        private static IWorkspace pwps = null;
        private static AoInitialize _arcObjects = null;

        static void Main(string[] args)

            IWorkspaceFactory workspaceFactory = null;


            workspaceFactory = new FileGDBWorkspaceFactoryClass();
            //Path of file GDB.  Change it if necessary
            string connstr = @"C:\GisData\PowerMap.gdb";

            pwps = workspaceFactory.OpenFromFile(connstr, 0);

            if (pwps != null)
                //First, a classic case.  This one works!
                ParseAddressSample("10 main st");
                //Exception thrown with this string
                ParseAddressSample("main st");

            Console.WriteLine("Press any key to finish");

        private static void ParseAddressSample(string freeFormat)
            LocatorManagerClass locatorManager = new LocatorManagerClass();
            ILocatorWorkspace locatorWorkspace = (ILocatorWorkspace)locatorManager.GetLocatorWorkspace(pwps);
            ILocator locator = locatorWorkspace.GetLocator("StreetSegment");

            if (locator != null)
                // Get the Locator and QI to ISimpleStandardization
                ISimpleStandardization standardizer = (ISimpleStandardization)locator;

                    // Get the Standardization fields from the locator
                    //  exception on the 2nd call "Specified cast is not valid."
                    IPropertySet standardizedAddressSet = standardizer.SimpleStandardizeAddress(freeFormat);
                catch (Exception ex)
                    Console.WriteLine("Problem parsing (" + freeFormat + ") " + ex.Message);


        #region "ESRi licencing"