Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

I'm trying to perform the following operation:

 IPropertySet addressProperties = reverseGeocoding.ReverseGeocode(point, false);

And I get this error: Exception from HRESULT: 0x80040217

Is there some function to get a human readable form of this error?

share|improve this question
up vote 6 down vote accepted

Often you can use the ISupportErrorInfo interface and GetErrorInfo system call in conjunction; many classes implement this to provide human-readable exception data.

Also, some common HRESULT codes for geocoding.

share|improve this answer
Wow: GEOCODING_E_REVERSE_GEOCODE_NO_ADDRESS_FOUND. They really ought to have the HRESULTs on that page as well (I sent feedback on that page requesting that they include the HRESULT value, but I haven't had a lot of luck with sending feedback to them in the past). – Michael Todd Oct 19 '10 at 4:22
There is no need to access ISupportErrorInfo in .NET, since any errors are translated to a COMException which, if the class implements ISupportErrorInfo, does include the available information. – Petr Krebs Feb 3 '11 at 8:59

So far I have not found anything to help me ease the debugging experience of the ESRI COMException, and therefore decided to try and do something about it. I put the solution on for everybody to use.

I used the resource ArcObjects error codes and copied all the error messages with codes and enums into a text file, about 1900+ lines. Not all exceptions are documented even, and many are just to generic to get anything useful out of.

The "enums" look like this CADASTRAL_E_OPERATION_FAILED, with a regex I then picked out "the first word the underscore and then the second word" CADASTRAL_E as that seemed to be a common pattern that i could group the error codes by per assembly/namespace

I then filled a second text file with the shortened enums and the belonging assemblies/namespaces.

When that was done I created a console project, where i read all the lines from the two files and with an algorithm created a Dictionary with the namespaces as key, and the value as a second Dictionary where the key was the 10 digit error code, and the value as an EsriError class containing the message etc.

In the end I then wrote out the code as a Dictionary initializer to a new text file by iterating over the Dictionaries, and then copied the code into my project.

Since the COMException.Source attribute sais which assembly/namespace the error was thrown in, I can use that to lookup the Dictionary containing all the error codes for that assembly.

To find the correct message to go with the error code i then do a lookup in the retrieved dictionary with the COMException.ErrorCode as the key, and then I either get back the error message or an message telling me that the ComExceptionInterpreter had no message associated with the error code.

Hope this will help somebody, and if anybody have anything to add, let me know! You can also fork the gist to make it your own.

ESRI Error Lookup Utility

share|improve this answer
This is a very useful piece of work ! But note, that in many cases there are error codes that are either generic (e.g "unspecified error") or they are simply not documented at all. There are also cases where the same generic error string is re-used, e.g "SDE Error.". However, the error itself is described in the enum, for example: FDO_E_SE_INVALID_USER -2147216118 "SDE Error." could be altered to FDO_E_SE_INVALID_USER -2147216118 "SDE Invalid user." It should therefore be possible to add an error string with a more descriptive message. Good work ! – Oyvind Aug 5 '13 at 7:57
While that's handy, I don't really see why you asked the question to which you already knew the answer and wrote the code to. – Paul Aug 5 '13 at 18:36
Well, you know that there is an option to answer your question straight away while writing your question. I wanted to contribute my work to the community so hopefully somebody wouldn't have to do this all over again, but if people don't feel its usefull sure ill take it away... – furier Aug 5 '13 at 18:41
I'm not detracting from its usefulness, it's just that this answer should be merged with @patrickinmpls thread. At any rate, this can be considered a duplicate thread. – Paul Aug 5 '13 at 18:48

Convert the Hex code to Decimal.

I usually take these steps:

  1. Convert the HRESULT to binary

       8    0    0    4    0    2    1    7
    1000 0000 0000 0100 0000 0010 0001 0111
  2. Since the most significant digit is 1, the number is negative. We must calculate the 2's compliment. First, find the 1's compliment by NOT'ing the binary number.

    0111 1111 1111 1011 1111 1101 1110 1000
  3. Now add 1 to make the 2's compliment

    0111 1111 1111 1011 1111 1101 1110 1001
  4. Convert the new binary number to decmial (I use this page)

share|improve this answer
Frankly, the decimal equivalent of the hex error code is even harder for a human to read. Typically such error codes are either (a) abstract values that index into a list of explanations, in which case the conversion is useless, or (b) a concatenation of bits, each of which provides a discrete binary flag, in which case the conversion makes it much more difficult to identify the bit pattern. – whuber Aug 5 '13 at 20:59

COMException class has the ErrorCode property, which you can compare against any of the error code enumerations, for example esriGeocodingError.

share|improve this answer
Do you have any clever way of getting the enum string corresponding to the ErrorCode property in a generic way, like if you don't know in advance which enumeration it is in? – blah238 Aug 11 '11 at 22:59
I also see that the enumerations have summaries that could possibly be retrieved as well. Seems like there would be something built in to put 2 and 2 together... – blah238 Aug 11 '11 at 23:06
@blah238, did you ever develop a way to get the ErrorCode in a generic way? Also, do you know how to access each error enumeration's summary? I can see the summary when I hover over the enum in Vis Studio, but am not sure you to actually capture it programmatically. – rgwozdz Oct 1 '11 at 2:57
@blah238 and rgwozdz if you take a look at my answer to this post, its the closest iv gotten to getting a generic human readable error message, just feed the COMException to the error lookup method and you will get it. – furier Aug 5 '13 at 21:45

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.