473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HResult

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
4 8551
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kimmo Laine | last post by:
Hi, we have a (unmanaged) ATL COM server, which implements two interface: ITestInterface1 and ITestInterface2. Both of these interfaces also support the ISupportErrorInfo-interface. Interface...
1
by: Display Name | last post by:
Exception class has HRESULT as protected member. Is there a header file or tool to get the entire mapping of C# Exception to HRESULT? Any tools / header file / links appreciated
1
by: Manoj | last post by:
Hi, In our application we reference com components written in c++.When errors occur the messages appear like this 'Exception from HRESULT: 0xC0068002" is there a way to convert this HResult...
4
by: KC | last post by:
Is this Exception from HRESULT: 0x800401A8 an error or a bug? I've been trying to build a chart in Excel through VB.net (which isn't documented) so I'm running completely blind. What examples...
4
by: cpajoe2001 | last post by:
I am not sure if this is the proper place to put this thread but I have run into a road block. I am writing a web app that will create groups in Active Directory then add users to those groups. I...
6
by: =?Utf-8?B?Um9i?= | last post by:
Hi, If I call my own DLL from Javascript, a HRESULT is returned. Javascript cannot cast this to an integer. Is there any other way of typecasting this returnvalue to integer, wihout using the...
3
by: wundertier | last post by:
Hi, I'm accessing COM objects from C#.net. In case of error a COMException is thrown which includes the HRESULT. But how do I get the description for the HRESULT? The Message property of the...
11
by: Academia | last post by:
I've been Googling and there is many many hits but I can't find what I want. I've read at one time how DotNET treats HRESULT but can't find it now. Does it return HRESULT unchanged or does it...
4
by: yogarajan | last post by:
The specified module could not be found. (Exception from HRESULT: 0x8007007E) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.