How can i get the hResult of the Exception class 
Author Message
 How can i get the hResult of the Exception class

As we know the hresult contains the 'Error Number' thrown by a com
component. However if I try to code to the hReuslt property I get:

'System.Exception.Protected Overloads Property HResult() As Integer' is not
accessible in this context because it is 'Protected'.

I have the follwoing error handler code:

Catch e as exception
    msgbox cstr(e.hresult)

It seems kind of rediculous that I need to build a class that inherits
exception so that i can shadow the hResult property to return it from the
Mybase object.

I must be missing something.



Mon, 27 Dec 2004 03:32:15 GMT  
 How can i get the hResult of the Exception class
Joe,
You caught a normal Exception object. You did not catch an
'ExternalException'.

According to the help for ExternalException it is 'The base exception for
all COM interop exceptions and structured exception handling (SEH)
exceptions'.

It has a public ErrorCode property that represents the HResult.

Hope this helps
Jay


Quote:
> As we know the hresult contains the 'Error Number' thrown by a com
> component. However if I try to code to the hReuslt property I get:

> 'System.Exception.Protected Overloads Property HResult() As Integer' is
not
> accessible in this context because it is 'Protected'.

> I have the follwoing error handler code:

> Catch e as exception
>     msgbox cstr(e.hresult)

> It seems kind of rediculous that I need to build a class that inherits
> exception so that i can shadow the hResult property to return it from the
> Mybase object.

> I must be missing something.



Tue, 28 Dec 2004 10:43:15 GMT  
 How can i get the hResult of the Exception class
Hi Joe,

As you've seen, HResult is protected. To get its value, pass any
Exception-derived object to the System.Runtime.InteropServices.Marshal
type's shared GetHRForException method.

Regards,

Mark


As we know the hresult contains the 'Error Number' thrown by a com
component. However if I try to code to the hReuslt property I get:

'System.Exception.Protected Overloads Property HResult() As Integer' is not
accessible in this context because it is 'Protected'.

I have the follwoing error handler code:

Catch e as exception
    msgbox cstr(e.hresult)

It seems kind of rediculous that I need to build a class that inherits
exception so that i can shadow the hResult property to return it from the
Mybase object.

I must be missing something.



Wed, 29 Dec 2004 03:59:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENI

2. Question about "Exception from HRESULT: 0x80131019"

3. Exceptions and HResults revisited

4. Getting HRESULT Parameters in VBS

5. Sometimes GetActiveObject gets HRESULT 0x80070776

6. getting the HRESULT from a C++ COM Interface method

7. Not getting Events from classes within classes.

8. odbcConnection Class security exception.

9. Seeking help to extend Exception class

10. Seeking help for Custom Exception Class

11. best practice, exceptions in class constructor

12. Inheriting Exception Classes

 

 
Powered by phpBB® Forum Software