473,788 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get the description for a HRESULT?

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 COMException does not contain any useful
information.
Example (I've got a german OS only, so I don't know the exact english
version of these texts):
HRESULT is: 800706ba
Message is: "Die COM-Klassenfactory für die Komponente mit CLSID
{E36D3A64-1FCE-11D3-B2EF-00104B066E1A} konnte aufgrund des folgenden
Fehlers nicht abgerufen werden: 800706ba."
(The COM-factory for the component with CLSID {E36D3A64-1FCE-11D3-
B2EF-00104B066E1A} could not be called because of the following error:
800706ba.)

What I would like to get is what tools like ERRLOOK return:
"Der RPC-Server ist nicht verfügbar."
(RPC server is not available.)

Is there a way to access these error texts from C#?

Thanks for help!

Steffi
Jan 18 '08 #1
3 15933
On 18 Jan., 10:55, "wundert...@web .de" <wundert...@web .dewrote:
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 COMException does not contain any useful
information.
Example (I've got a german OS only, so I don't know the exact english
version of these texts):
HRESULT is: 800706ba
Message is: "Die COM-Klassenfactory für die Komponente mit CLSID
{E36D3A64-1FCE-11D3-B2EF-00104B066E1A} konnte aufgrund des folgenden
Fehlers nicht abgerufen werden: 800706ba."
(The COM-factory for the component with CLSID {E36D3A64-1FCE-11D3-
B2EF-00104B066E1A} could not be called because of the following error:
800706ba.)

What I would like to get is what tools like ERRLOOK return:
"Der RPC-Server ist nicht verfügbar."
(RPC server is not available.)

Is there a way to access these error texts from C#?

Thanks for help!

Steffi
Maybe you should take a look at
System.Runtime. InteropServices .Marshal.ThrowE xceptionForHR, this
should convert HRESULTs into .Net Exceptions with the appropriate text
and throw them. If you only need to know the message of the exception
you could just catch the exception right away again, though there may
be a more elegant solution that I am not aware of.

hth,
Kevin Wienhold
Jan 18 '08 #2
Sometimes, calling the Windows API GetLastError and FormatMessage functions
will yield some additional data about the error, depending on the software
which throws the error. See:

http://msdn2.microsoft.com/en-us/lib...60(VS.85).aspx

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

<wu********@web .dewrote in message
news:4c******** *************** ***********@n20 g2000hsh.google groups.com...
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 COMException does not contain any useful
information.
Example (I've got a german OS only, so I don't know the exact english
version of these texts):
HRESULT is: 800706ba
Message is: "Die COM-Klassenfactory für die Komponente mit CLSID
{E36D3A64-1FCE-11D3-B2EF-00104B066E1A} konnte aufgrund des folgenden
Fehlers nicht abgerufen werden: 800706ba."
(The COM-factory for the component with CLSID {E36D3A64-1FCE-11D3-
B2EF-00104B066E1A} could not be called because of the following error:
800706ba.)

What I would like to get is what tools like ERRLOOK return:
"Der RPC-Server ist nicht verfügbar."
(RPC server is not available.)

Is there a way to access these error texts from C#?

Thanks for help!

Steffi
Jan 18 '08 #3
<wu********@web .dewrote in message
news:4c******** *************** ***********@n20 g2000hsh.google groups.com...
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 COMException does not contain any useful
information.
Example (I've got a german OS only, so I don't know the exact english
version of these texts):
HRESULT is: 800706ba
Message is: "Die COM-Klassenfactory für die Komponente mit CLSID
{E36D3A64-1FCE-11D3-B2EF-00104B066E1A} konnte aufgrund des folgenden
Fehlers nicht abgerufen werden: 800706ba."
(The COM-factory for the component with CLSID {E36D3A64-1FCE-11D3-
B2EF-00104B066E1A} could not be called because of the following error:
800706ba.)

What I would like to get is what tools like ERRLOOK return:
"Der RPC-Server ist nicht verfügbar."
(RPC server is not available.)

Is there a way to access these error texts from C#?

Thanks for help!

Steffi

I don't think that "The RPC server is unavailable." is more usefull than
"The COM-factory for the component with CLSID
{E36D3A64-1FCE-11D3-B2EF-00104B066E1A} could not be called because of the
following error:800706ba. )
The first is the Win32 error message for error code "06ba", that is the
lowest 16 bits of HRESULT, the latter is the COM error message for
0x800706ba.
So, IMO the latter is more descriptive, it tell's you that a Class with
CLSID .... could not be constructed because it's class factory could not be
called due to: 800706ba.
THat means that your out-proc server could not be activated/launched,
probably because of a security issue (the 7 in 8007).

If you really need the HRESULT message you'll have to call
Marshal.GetExce ptionForHR(), like so:

...
int hr unchecked ((int) 0x800706ba);
Marshal.GetExce ptionForHR(hr). Message

Willy.

Jan 18 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8588
by: lakshmi | last post by:
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.
3
7852
by: Lekyan | last post by:
I have problem setting the password for an ADAM user using C#. I used the SetPassword code given in the Microsoft page, changed several parameters, but ran into an exception. I wonder if other people have solved this problem. But I have searched Google groups for a couple days but still couldn't get a solution. I copied the code from: ...
1
6342
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 implementation is divided into two class: CTestInterface2, which implements the ITestInterfac2, and CTestInterface1, which implements ITestInterface1 AND ITestInterface2.
1
3066
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
11041
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 value string (0xC0068002) and convert it into an int value thanks in advance
4
5323
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 I have found are from VB6 which doesn't convert well. When I do try a new piece of code like: oChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom
2
1998
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, If I want to convert LPCTSTR and HRESULT to standard C/C++ data type (like char*, int, long, etc.), I am wondering what standard data types should I convert to be safe and do not lose and data precise? thanks in advance, George
6
3251
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 exception method which is described everywhere ? Please note that I am unfamiliar with javascript, I am used to C/C++. My Javascript call looks like : var result;
11
5941
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 check it for error-return or what? Thanks for any help
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.