Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"));
ILocatorManager2 locatorManager2 = obj as ILocatorManager2;
ILocatorWorkspace locatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath(@"Z:\ESRI\DataMaps10\streetmap_na");
locator = locatorWorkspace.GetLocator("Street_Addresses_US");
IAddressGeocoding addressGeocoding = (IAddressGeocoding)locator;  //this  fails

Inspecting the addressCoding object gives

'addressGeoCoding.matchFields' threw an exception of type Interop.COMException

share|improve this question

check if the locator object is of the type IAddressGeocoding before casting it to that interface.

If(locator is IAdressGeocoding)
   IAddressGeocoding addressGeocoding = (IAddressGeocoding)locator;
share|improve this answer
surprisingly enough it is... – patrick Sep 8 '10 at 18:47
@iterationx, Noticed that the locator is not declared in the code snippet, how is it declared? I had som issues with some objects that got garbaged collected, setting the variable as static or as a class variable solved that.. – MathiasWestin Sep 8 '10 at 19:04
I checked its not out of scope, I'll keep that in mind tho, thanks – patrick Sep 8 '10 at 19:10

With ArcEngine, you need to be sure to call IAoInitialize.Initialize when your app starts. Otherwise it throws exceptions in really strange places.

share|improve this answer
furthermore, at 10.0, you also need to Bind to a runtime before you call Initialize (there's a helper method to both at once)… – bFlood Sep 9 '10 at 11:10
up vote 1 down vote accepted

My .loc file was corrupted

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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