Help!! VC 7/ ATL/ XML 
Author Message
 Help!! VC 7/ ATL/ XML

Hi!

I've got very strange problem  - I cannot compile very simple code:
...
__interface ITest : public IDispatch

{

[id(1), helpstring("Initialize component")]

HRESULT Init([in] IXMLDOMNode* xmlDoc);

[id(2), propget, helpstring("Return list of attached resources")]

HRESULT Resources([out, retval, satype("BSTR")] SAFEARRAY** val);

Quote:
};

...

class ATL_NO_VTABLE CTest :

public ITest

{

public:

CTest()

{

public:

STDMETHOD(Init)(MSXML2::IXMLDOMNode* xmlDoc);

STDMETHOD(get_Resources)(SAFEARRAY** pVal);

Quote:
};

I've got compiler error:

error C2440: 'initializing' : cannot convert from 'VARIANT' to 'IXMLDOMNode *'

And if you take a look on generated code, you will find something like:

...

#injected_line 23 "d:\\localsource\\ink\\ink4windows\\applet\\test.cpp"
    virtual HRESULT STDMETHODCALLTYPE ITest::Invoke(......
.....
        VARIANT v0;
        VARIANT* v;
        switch (dispIdMember) {
        case 1:
            {
                if (pDispParams->cArgs != 1) {
                    return DISP_E_BADPARAMCOUNT;
                }
                v = rgpVars[0];
                if (v->vt == (VT_VARIANT | VT_BYREF)) {
                    v = V_VARIANTREF(v);
                }
                IXMLDOMNode* i1 = *v;    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                hr = ((::ITest*) this)->Init(i1);
                break;
            }
        case 2:
            {
                if (pDispParams->cArgs != 0) {
                    return DISP_E_BADPARAMCOUNT;
                }
                SAFEARRAY* i1;
                hr = ((::ITest*) this)->get_Resources(&i1);
                if (pVarResult != 0) {
                    V_VT(pVarResult) = (VT_ARRAY | VT_BSTR);
                    V_ARRAY(pVarResult) = (SAFEARRAY*) i1;
                }
                break;
            }
        default:
            return DISP_E_MEMBERNOTFOUND;
        }
        return hr;
And this does not make any sence - is it compiler bug or I'm doing somethinf wrong?

Also, if you change second method declaration, skipping satype("BSTR")
HRESULT Resources([out, retval)] SAFEARRAY** val);

everything will be OK, but instead compiler will use IDispatchImpl instead.

So, what I should do??

Michael



Wed, 23 Feb 2005 01:15:14 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help for XML in VC

2. Any updates in ATL/ATL Server in VC 7.1

3. Problem converting VC6 ATL component to a .NET 2003 VC ATL component

4. Heap Usage problem with ATL exe - VC 5.0/ATL 2.1

5. Newbie Q: vc.atl vs vc.activex.templatelib

6. Error when XML-parsing large SOAP responses in a VC7/ATL project

7. Downloading XML data in an ATL component

8. ATL COM... apply xsl to xml

9. how to use xml in vc.net?

10. XML-Doc from VC source codes...

11. problem with using vc(com) parse xml

12. Question About XML programming in VC

 

 
Powered by phpBB® Forum Software