AtlReportError not working in ATL 7.0 (Injected code doesn't handle ErrorInfo properly) 
Author Message
 AtlReportError not working in ATL 7.0 (Injected code doesn't handle ErrorInfo properly)

Hi David,


Quote:
> (Also posted similar topic to m.p.v.atl)

> I've been trying to get the AtlErrorReport method to work like it did
> with ATL 3, but when i use my component in VBScript, it isn't able to
> obtain the custom error informatin (eg. description) that i've tried to
> pass back.

> Using the de{*filter*} to trace through the code, it appears that the
> injected code isn't properly passing through the ErrorInfo data.

> I've attached a simple testcase project, that was created with the VS
> wizard and a simple method that should return the error stuff.

> Using the following test script:
> (doover.vbs)
> ==============================
> Sub DispErrors
> With WScript
> .echo "Description: " & Err.Description
> .echo "HelpContext: " & Err.HelpContext
> .echo "Helpfile: " & err.helpfile
> .echo "Number: " & Hex(err.number)
> .echo "Source: " & err.Source
> .echo ""

> End With

> End Sub

> Dim Doover
> Set Doover = CreateObject("TestComponent.Doover")

> On Error Resume Next
> Doover.Thingy "hey"

> DispErrors
> Set Doover = Nothing

> =====================================

> This displays the following (eg. doesn't display the custom text, just
> the standard Win32 message for the error code).

> c:\Tmp>doover.vbs
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

> Description: Invalid procedure call or argument
> HelpContext: 0
> Helpfile:
> Number: 5
> Source: Microsoft VBScript runtime error

> If i replace the HRESULT code with a user-defined one, then the info i
> get back is even less helpful:

> eg.
> return AtlReportError(__uuidof(CDoover), L"My error text",
> __uuidof(IDoover), MAKE_HRESULT(1, FACILITY_ITF, 0x200 + 1));

> c:\Tmp>doover.vbs
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

> Description:
> HelpContext: 0
> Helpfile:
> Number: 80040201
> Source:

> Now, the interesting thing is that i discovered some sample code in
> MSDN: the samples for the article
> http://www.*-*-*.com/

> These obviously don't use the new attribute stuff, but they actually
> work properly... calling one of the objects from this sample with my
> .vbs file gives the expected result:
> Description: <MSGS><MSG><D>Demo Error test
> 20</D><FN>goodobject.cpp</FN><LN>28</

LN></MSG><MSG><D></D><LN>25</LN><FN>goodobject.cpp</FN><EC>0</EC></MSG></MSG
S>

Quote:

> HelpContext: 0
> Helpfile:
> Number: 80040200
> Source: COMErrorsDemo.GoodObject.1

> The fact that this old example works, makes me pretty sure that 7.0's
> injected code is the culprit.

I got a solution:

In the class definition replace the following:

class ATL_NO_VTABLE YourClass :
   public IYourItf
{
...

Quote:
};

with good old:

class ATL_NO_VTABLE YourClass :
   public IDispatchImpl<IYourItf>
{
...

Quote:
};

This will give you the typelib driven implementation of IDispatch. If you
changed the version number of your type library be sure to use: public
IDispatchImpl<IYourItf, &__uuidof(IYourItf), &CAtlModule::m_libid,
YourMajorVersion, YourMinorVersion>

HTH,
Sven



Sun, 05 Sep 2004 00:28:11 GMT  
 AtlReportError not working in ATL 7.0 (Injected code doesn't handle ErrorInfo properly)

Quote:

>I got a solution:

>In the class definition replace the following:

>class ATL_NO_VTABLE YourClass :
>   public IYourItf
>{
>...
>};

>with good old:

>class ATL_NO_VTABLE YourClass :
>   public IDispatchImpl<IYourItf>
>{
>...
>};

>This will give you the typelib driven implementation of IDispatch. If you
>changed the version number of your type library be sure to use: public
>IDispatchImpl<IYourItf, &__uuidof(IYourItf), &CAtlModule::m_libid,
>YourMajorVersion, YourMinorVersion>

>HTH,
>Sven

Excllent.... i'll give that a try.

I would hope that M$ would investigate the original problem and fix it
if it is a real bug.

-dave

--
David Gardiner <>< Senior Programmer with UniSAnet Project.
Flexible Learning Centre, Underdale Campus, University of South Australia



Sun, 05 Sep 2004 05:29:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. AtlReportError not working in ATL 7.0

2. event_source attribute injected code does not work in thread

3. DAO doesn't work with Access 7.0

4. AtlReportError doesn't

5. AtlReportError doesn't

6. Apparent BUG in Injected ATL Code for VC++ .NET

7. Windowless control (ATL) doesn't work correctly on VC++ dialog resource

8. #ifndef/#define doesn't work in ATL header

9. ActiveX control using ATL doesn't work in Excel

10. ClassWizard doesn't work with ATL projects / Stock Events

11. PROBLEM: ATL OBJECT WIZARD DOESN'T WORK

12. PROBLEM: NEW ATL OBJECTS DOESN'T WORK

 

 
Powered by phpBB® Forum Software