Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with IErrorInfo and ISupporErrorInfo

0 views
Skip to first unread message

Roy Chastain

unread,
Jan 17, 2001, 2:11:48 PM1/17/01
to
I have a server that implements ISupportErrorInfo (via check box in
ALT template). I try to access the error return in the client and end
up with an exception in Kernel32 in IsBadReadPtr

The code in the client is
hRes = m_pIGenLicense->GenerateLicense(&product_version,
&file_version,&OS_version,1,&product_version);
if (hRes != S_OK)
{
_bstr_t temp;
CComPtr<IErrorInfo> pError;
CComBSTR strError;
GetErrorInfo(0, &pError);
pError->GetDescription(&strError);
temp = strError;
::MessageBox(NULL,temp, _T("Error"), MB_ICONEXCLAMATION);
}

The error occurs on the call to GetErrorInfo(&pError);

I admit I don't understand this part AT ALL and I was only able to
find one example, (which I tried to copy).

PS. The server class was derived from ISupportErrorInfo not
ISupportErrorInfoImpl as suggested by the books on the subject. I
have tried both with the same lack of results.

Complied with July 2000 Platform SDK and VC 6.0 SP 4 with ATLBASE.H
replaced by the one from the SDK.

Thanks for the help

-------------------------------------------
Roy Chastain
KMSystems, Inc.

Jon Dahl

unread,
Jan 17, 2001, 3:01:37 PM1/17/01
to
The problem is:

CComPtr<IErrorInfo> pError;

Don't declare a smart pointer. Let the GetErrorInfo function allocate the
interface for you.

IErrorInfo* pError = NULL;

GetErrorInfo(0, &pError);

if(pError != NULL)
{
.... Get the description here.

}

pError->Release();

Good luck,

JD

Roy Chastain <r...@kmsys.com> wrote in message
news:2irb6t8m0nj8bik96...@4ax.com...

Roy Chastain

unread,
Jan 17, 2001, 3:34:12 PM1/17/01
to
Thanks, but I am afraid that did not work either. It still get the
error. Could this possible mean that the error info built by the
server is in an invalid format or something like that? I have not
faith that I got that part right either.

On Wed, 17 Jan 2001 14:01:37 -0600, "Jon Dahl" <jd...@technium.com>
wrote:

Ken Brady

unread,
Jan 18, 2001, 8:43:54 AM1/18/01
to
Has your server called CComCoClass::Error(...) before returning its error
code to the client?

kb

"Roy Chastain" <r...@kmsys.com> wrote in message
news:2irb6t8m0nj8bik96...@4ax.com...

Roy Chastain

unread,
Jan 18, 2001, 9:13:42 AM1/18/01
to
Lets that I put the code in and it appears to being called.

On Thu, 18 Jan 2001 08:43:54 -0500, "Ken Brady" <kbr...@ibes.com>
wrote:

Allen Weng

unread,
Jan 29, 2001, 2:54:23 AM1/29/01
to
I have no problem using IErrorInfo. I have a simple server that creates and
sets error object, and a client on another end to retrieve the error
object. It always runs successfully. All are written in ATL.

In the server, create and set an error object like below:

ICreateErrorInfo* pcei;
IErrorInfo* pei;

HRESULT hr;

hr = CreateErrorInfo(&pcei);
hr = pcei->QueryInterface(IID_IErrorInfo, (LPVOID*) &pei);
if (SUCCEEDED(hr))
{
SetErrorInfo(0, pei);
pei->Release();
}
pcei->Release();
return E_FAIL;

In the client side, retrieve the erro object:

HRESULT hr;
IErrTest* pErrTest;

hr = ::CoCreateInstance(CLSID_ErrTest, NULL, CLSCTX_ALL, IID_IErrTest,
(void**)&pErrTest);
if (FAILED(hr))
return;

hr = pErrTest->CallException(); // An exception is generated in the server.

if (FAILED(hr))
{
ISupportErrorInfo *pSupport;
hr = pErrTest->QueryInterface(IID_ISupportErrorInfo, (void**)&pSupport);

if (SUCCEEDED(hr))
{
hr = pSupport->InterfaceSupportsErrorInfo(IID_IErrTest);
if (hr == S_OK) {
IErrorInfo *pErrorInfo;
hr = GetErrorInfo(0, &pErrorInfo);
if (SUCCEEDED(hr)) {
pErrorInfo->Release();
}
}
pSupport->Release();
}
}

I never run into the similar problem before. Just curious about how to
reproduce your problem.

-- Allen


0 new messages