IErrorInfo and ISupporErrorInfo Options

flag
 6/> messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Roy Chastain  
View profile
 More options Jan 17 2001, 2:14 pm
Newsgroups: microsoft.public.vc.atl
From: Roy Chastain ...@kmsys.com>
Date: Wed, 17 Jan 2001 14:11:48 -0500
Local: Wed, Jan 17 2001 2:11 pm
Subject: Need help with IErrorInfo and ISupporErrorInfo
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;
         CComPtrIErrorInfo> 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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Dahl  
View profile
 More options Jan 17 2001, 3:10 pm
Newsgroups: microsoft.public.vc.atl
From: "Jon Dahl" ...@technium.com>
Date: Wed, 17 Jan 2001 14:01:37 -0600
Local: Wed, Jan 17 2001 3:01 pm
Subject: Re: Need help with IErrorInfo and ISupporErrorInfo
The problem is:

CComPtrIErrorInfo> 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 ...@kmsys.com> wrote in message

news:2irb6t8m0nj8bik96cegrf90adq0f14278@4ax.com...

- Show quoted text -

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Chastain  
View profile
 More options Jan 17 2001, 3:38 pm
Newsgroups: microsoft.public.vc.atl
From: Roy Chastain ...@kmsys.com>
Date: Wed, 17 Jan 2001 15:34:12 -0500
Local: Wed, Jan 17 2001 3:34 pm
Subject: Re: Need help with IErrorInfo and ISupporErrorInfo
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" ...@technium.com>
wrote:

-------------------------------------------
Roy Chastain
KMSystems, Inc.
- Show quoted text -

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ken Brady  
View profile
 More options Jan 18 2001, 8:54 am
Newsgroups: microsoft.public.vc.atl
From: "Ken Brady" ...@ibes.com>
Date: Thu, 18 Jan 2001 08:43:54 -0500
Local: Thurs, Jan 18 2001 8:43 am
Subject: Re: Need help with IErrorInfo and ISupporErrorInfo
Has your server called CComCoClass::Error(...) before returning its error
code to the client?

kb

"Roy Chastain" ...@kmsys.com> wrote in message

news:2irb6t8m0nj8bik96cegrf90adq0f14278@4ax.com...

- Show quoted text -

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Chastain  
View profile
 More options Jan 18 2001, 9:20 am
Newsgroups: microsoft.public.vc.atl
From: Roy Chastain ...@kmsys.com>
Date: Thu, 18 Jan 2001 09:13:42 -0500
Local: Thurs, Jan 18 2001 9:13 am
Subject: Re: Need help with IErrorInfo and ISupporErrorInfo
Lets that I put the code in and it appears to being called.

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

-------------------------------------------
Roy Chastain
KMSystems, Inc.
- Show quoted text -

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Allen Weng  
View profile
 More options Jan 29 2001, 3:01 am
Newsgroups: microsoft.public.vc.atl
From: yweg_sp...@sina.com (Allen Weng)
Date: Mon, 29 Jan 2001 07:54:23 GMT
Local: Mon, Jan 29 2001 2:54 am
Subject: Re: Need help with IErrorInfo and ISupporErrorInfo
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

登录后才可评论.