HResult

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.
 
M

Mickey Williams

The general .NET pattern is to indicate failure with an exception rather
than return value.
 
L

lakshmi

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.
 
L

lakshmi

thanks again.
Yes, the client checks for FAILED(hr).
I'm throwing ArgumentException,
ArgumentOutOfRangeException etc. from my C# code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top