By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,383 Members | 2,075 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,383 IT Pros & Developers. It's quick & easy.

HResult

P: n/a
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.

Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The general .NET pattern is to indicate failure with an exception rather
than return value.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com
"lakshmi" <lm@nospam.net> wrote in message
news:10****************************@phx.gbl...
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.

Nov 15 '05 #2

P: n/a
thanks Mickey, I'm actually reading your Visual C#.NET
core reference book.
-----Original Message-----
The general .NET pattern is to indicate failure with an exception ratherthan return value.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Presswww.servergeek.com
"lakshmi" <lm@nospam.net> wrote in message
news:10****************************@phx.gbl...
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.

.

Nov 15 '05 #3

P: n/a
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.
-----Original Message-----
The general .NET pattern is to indicate failure with an exception ratherthan return value.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Presswww.servergeek.com
"lakshmi" <lm@nospam.net> wrote in message
news:10****************************@phx.gbl...
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.

.

Nov 15 '05 #4

P: n/a
thanks again.
Yes, the client checks for FAILED(hr).
I'm throwing ArgumentException,
ArgumentOutOfRangeException etc. from my C# code.
-----Original Message-----
"lakshmi" <lm@nospam.net> wrote in message
news:04****************************@phx.gbl...
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.
What kind of exception are you throwing? Are you using

FAILED(hr)?
--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Presswww.servergeek.com
>-----Original Message-----
>The general .NET pattern is to indicate failure with an

exception rather
>than return value.
>
>--
>Mickey Williams
>Author, "Microsoft Visual C# .NET Core Reference", MS

Press
>www.servergeek.com
>
>
>"lakshmi" <lm@nospam.net> wrote in message
>news:10****************************@phx.gbl...
>> 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.
>>
>>
>>
>
>
>.
>

.

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.