Re: GetErrorInfo not working. Help !!!
- From: diablo <diablo@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 Oct 2006 22:14:01 -0700
Thanks for your kind help. But my interface is already supporting
ISupportErrorInfo. My client code is already checking for these conditions.
See the following code:
ISupportErrorInfo *pError = NULL ;
hr = p->QueryInterface(IID_ISupportErrorInfo, (void **)&pError) ;
if(FAILED(hr))
{
cout << "E_NOINTERFACE"<< endl;
}
hr = p->Error->InterfaceSupportsErrorInfo(__uuidof(ITest)) ;
if(FAILED(hr))
{
cout << "Does not support rich error information"<< endl;
}
IErrorInfo *pErrorInfo ;
hr = GetErrorInfo(0, &pErrorInfo) ;
It fails here. hr returns S_FALSE. All the other calls are succeeding. In
the COM server, I have also wrote the following statement:
Error("Allocation failed", IID_ITest, E_FAIL) ;
But still it is not working. Please help.
"Alexander Nickolov" wrote:
You must return an error HRESULT in order for the rich.
exception ionformation to be considered valid. Additionally,
your object must implement ISupportErrorInfo and mark
the interface you are calling as supporting rich exception
information. Your client code must check all these conditions,
otherwise you may be picking random leftover errors.
In your server it makes no sense whatsoever to use the default
arguments of CComCoClass::Error - e.g. IID_NULL and S_OK.
You need to pass the IID of your interface and the error HRESULT
you want returned to the client.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"diablo" <diablo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:05C64EA8-A9AE-4BA6-88AB-11887BCEB009@xxxxxxxxxxxxxxxx
I am using the following code to get error information from a COM
component.
I have created the component through ATL and have supported the IErrorInfo
interface. I am manually causing an error in my COM component like this:
Error("Some error message") ;
On the client side, I am writing this code after calling
InterfaceSupportsErrorInfo():
IErrorInfo * pErrorInfo ;
hr = GetErrorInfo(NULL, &pErrorInfo) ;
Here hr returns S_OK, but pErrorInfo contains NULL. What to do?
If I am calling the function in a try block then _com_error shows me the
error message. Why is this happening?
Thanks
- Follow-Ups:
- Re: GetErrorInfo not working. Help !!!
- From: Alexander Nickolov
- Re: GetErrorInfo not working. Help !!!
- References:
- Re: GetErrorInfo not working. Help !!!
- From: Alexander Nickolov
- Re: GetErrorInfo not working. Help !!!
- Prev by Date: Re: What is ActiveX properties ?
- Next by Date: Re: ByRef parameters from visual c++ to visual basic
- Previous by thread: Re: GetErrorInfo not working. Help !!!
- Next by thread: Re: GetErrorInfo not working. Help !!!
- Index(es):
Relevant Pages
|