0

I need to thrown an exception from C#.Net application and catch it in COM to process an error massage for my app.

I would like to know is there any accessible range of values of HRESULT that can be used for specific exception? Or it's OK to pass any value I want?

Thanks in advance

programmer0
  • 147
  • 7
  • Technically, you can use anything you want. And, if you own both sides it doesn't really matters. However, you should also be able to avoid exceptions and pass HRESULTs directly. – Simon Mourier Feb 23 '19 at 10:15
  • Throwing an exception in C# is the proper way to pass back an HRESULT. The range 0x800A0000..0x800AFFFF is set aside for application-specific errors. Use IErrorInfo in the calling app to retrieve the error message, often the most important part of a "something went wrong" diagnostic. Do keep in mind that you may well retrieve other HRESULT values, the CLR likes throwing exceptions by itself. – Hans Passant Feb 23 '19 at 10:53

0 Answers0