HResult

  • Thread starter Thread starter lakshmi
  • Start date Start date
L

lakshmi

Hi
We are rewriting a COM object in C#. The COM object
returns HRESULT for invalid arguments, null values etc.
The HRESULT is created using the MAKE_HRESULT macro in C++.
1.What is the C# equivalent of MAKE_HRESULT?
2.How do I return a HRESULT or an exception from my C#
program that would indicate a FAILURE.
Any help is appreciated.
Thanks.
 
The general .NET pattern is to indicate failure with an exception rather
than return value.
 
The client checks for failed HRESULTS. When I throw an
exception from my C# dll for example, when an invalid
argument is passed, now the client acts as if it received
a success HRESULT. Thanks for your help.
 
thanks again.
Yes, the client checks for FAILED(hr).
I'm throwing ArgumentException,
ArgumentOutOfRangeException etc. from my C# code.
 
Back
Top