Problems creating a valid object using CComObject<...>::CreateInstance 
Author Message
 Problems creating a valid object using CComObject<...>::CreateInstance

Hi,

i have the following problem, i have an API that was given to me in a
dll, i think the dll contains an ActiveX control.  I've been trying to
get our app, which is VC++6 (just converted it to .net, but none of it
is managed), to work with this dll.

i implemented one of their interfaces since i need to receive callback
events through it.  here is some of it:

class ATL_NO_VTABLE CConnEvents :
        public CComObjectRootEx<CComSingleThreadModel>,
        public CComCoClass<CSaxoConnEvents, &CLSID_SaxoConnEvents>,
        public IDispatchImpl<ISaxoConnEvents, &IID_ISaxoConnEvents,
&LIBID_nyfxLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
        public IConnectionEvents
{
public:
...

Quote:
}

IConnectionEvents - is their interface.
now, somewhere else in the code i need to pass a struct
IConnectionEvents * to another function.

when i do the following:

CComObject<CConnEvents> *m_pConnEvents;  

HRESULT ret=CComObject<CConnEvents>::CreateInstance(&m_pConnEvents);
_ASSERTE(SUCCEEDED(ret));

and pass m_pConnEvents into the function that expects struct
IConnectionEvents *. I get an error back from that function saying:
"Invalid pointer".  No, of course i have asked the people who provided
me w the dll, if they could point to what i am doing wrong, but they
said that i am on my own, not in so many words.

i think i need to create the the instance of CConnEvents differently,
just havent' figured out how that "differently" would take shape at
this point.

i've been reading the ms site and the google groups left and right,
but frankly at this point feel like my head is about to explode from
all of this reading.

so any help would be appreciated.

thanks,
inna



Tue, 25 Oct 2005 00:23:20 GMT  
 Problems creating a valid object using CComObject<...>::CreateInstance
Do you mention IConnectionEvents in your interface map? What kind of
interface is it - custom, dispinterface, dual? Show the IDL definition
of their interfaces and coclasses.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> i have the following problem, i have an API that was given to me in a
> dll, i think the dll contains an ActiveX control.  I've been trying to
> get our app, which is VC++6 (just converted it to .net, but none of it
> is managed), to work with this dll.

> i implemented one of their interfaces since i need to receive callback
> events through it.  here is some of it:

> class ATL_NO_VTABLE CConnEvents :
> public CComObjectRootEx<CComSingleThreadModel>,
> public CComCoClass<CSaxoConnEvents, &CLSID_SaxoConnEvents>,
> public IDispatchImpl<ISaxoConnEvents, &IID_ISaxoConnEvents,
> &LIBID_nyfxLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
> public IConnectionEvents
> {
> public:
> ...
> }

> IConnectionEvents - is their interface.
> now, somewhere else in the code i need to pass a struct
> IConnectionEvents * to another function.

> when i do the following:

> CComObject<CConnEvents> *m_pConnEvents;

> HRESULT ret=CComObject<CConnEvents>::CreateInstance(&m_pConnEvents);
> _ASSERTE(SUCCEEDED(ret));

> and pass m_pConnEvents into the function that expects struct
> IConnectionEvents *. I get an error back from that function saying:
> "Invalid pointer".  No, of course i have asked the people who provided
> me w the dll, if they could point to what i am doing wrong, but they
> said that i am on my own, not in so many words.



Tue, 25 Oct 2005 00:30:25 GMT  
 Problems creating a valid object using CComObject<...>::CreateInstance

Quote:

> Do you mention IConnectionEvents in your interface map?

yes.  here :

class ATL_NO_VTABLE CSaxoConnEvents :
        public CComObjectRootEx<CComSingleThreadModel>,
        public CComCoClass<CSaxoConnEvents, &CLSID_SaxoConnEvents>,
        public IDispatchImpl<ISaxoConnEvents, &IID_ISaxoConnEvents,
&LIBID_nyfxLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
        public IConnectionEvents
{
public:
        CSaxoConnEvents()
        {
        }

        ~CSaxoConnEvents() {}

        DECLARE_REGISTRY_RESOURCEID(IDR_SAXOCONNEVENTS)

        BEGIN_COM_MAP(CSaxoConnEvents)
                COM_INTERFACE_ENTRY(ISaxoConnEvents)
                COM_INTERFACE_ENTRY(IConnectionEvents)
                COM_INTERFACE_ENTRY(IDispatch)
        END_COM_MAP()

        DECLARE_PROTECT_FINAL_CONSTRUCT()

        HRESULT FinalConstruct()
        {
                return S_OK;
        }

        void FinalRelease()
        {
        }

...

Quote:
}
> What kind of interface is it - custom, dispinterface, dual? Show the IDL
> definition of their interfaces and coclasses.

here it is:

struct __declspec(uuid("5b8023d1-7b32-11d3-9a90-00105acc135c"))
IConnectionEvents : IUnknown
{
    //
    // Wrapper methods for error-handling
    //

    HRESULT LogInProgress (
        long StatusCode,
        _bstr_t StatusText );
    HRESULT LogInCompleted ( );
    HRESULT LogInFailed (
        long ErrorCode,
        _bstr_t ErrorText );
    HRESULT ReceiveCompleted (
        long BytesReceived );
    HRESULT DisConnected (
        long ErrorCode,
        _bstr_t ErrorText );
    HRESULT ListUpdated (
        ListTypes ListType,
        _bstr_t Parameters );
    HRESULT ListUpdateFailed (
        ListTypes ListType,
        _bstr_t Parameters,
        long ErrorCode,
        _bstr_t ErrorText );
    HRESULT RsUpdated (
        ListTypes ListType,
        _bstr_t Parameters );
    HRESULT RsUpdateFailed (
        ListTypes ListType,
        _bstr_t Parameters,
        long ErrorCode,
        _bstr_t ErrorText );
    HRESULT PasswordChanged ( );
    HRESULT PasswordChangeFailed (
        long ErrorCode,
        _bstr_t ErrorText );
    HRESULT TradeConfirmation (
        _bstr_t AccountId,
        long OrderId,
        _bstr_t Confirmation );
    HRESULT ForceInfo (
        VARIANT_BOOL WebPageURL,
        _bstr_t Text );
    HRESULT ModuleListUpdated (
        ClientSWCompatibilityLevels CompatibilityLevel );
    HRESULT MenuStructureUpdated (
        ClientSWCompatibilityLevels CompatibilityLevel );
    HRESULT AppCustomizationChanged ( );

    //
    // Raw methods provided by interface
    //

      virtual HRESULT __stdcall raw_LogInProgress (
        /*[in]*/ long StatusCode,
        /*[in]*/ BSTR StatusText ) = 0;
      virtual HRESULT __stdcall raw_LogInCompleted ( ) = 0;
      virtual HRESULT __stdcall raw_LogInFailed (
        /*[in]*/ long ErrorCode,
        /*[in]*/ BSTR ErrorText ) = 0;
      virtual HRESULT __stdcall raw_ReceiveCompleted (
        /*[in]*/ long BytesReceived ) = 0;
      virtual HRESULT __stdcall raw_DisConnected (
        /*[in]*/ long ErrorCode,
        /*[in]*/ BSTR ErrorText ) = 0;
      virtual HRESULT __stdcall raw_ListUpdated (
        /*[in]*/ ListTypes ListType,
        /*[in]*/ BSTR Parameters ) = 0;
      virtual HRESULT __stdcall raw_ListUpdateFailed (
        /*[in]*/ ListTypes ListType,
        /*[in]*/ BSTR Parameters,
        /*[in]*/ long ErrorCode,
        /*[in]*/ BSTR ErrorText ) = 0;
      virtual HRESULT __stdcall raw_RsUpdated (
        /*[in]*/ ListTypes ListType,
        /*[in]*/ BSTR Parameters ) = 0;
      virtual HRESULT __stdcall raw_RsUpdateFailed (
        /*[in]*/ ListTypes ListType,
        /*[in]*/ BSTR Parameters,
        /*[in]*/ long ErrorCode,
        /*[in]*/ BSTR ErrorText ) = 0;
      virtual HRESULT __stdcall raw_PasswordChanged ( ) = 0;
      virtual HRESULT __stdcall raw_PasswordChangeFailed (
        /*[in]*/ long ErrorCode,
        /*[in]*/ BSTR ErrorText ) = 0;
      virtual HRESULT __stdcall raw_TradeConfirmation (
        /*[in]*/ BSTR AccountId,
        /*[in]*/ long OrderId,
        /*[in]*/ BSTR Confirmation ) = 0;
      virtual HRESULT __stdcall raw_ForceInfo (
        /*[in]*/ VARIANT_BOOL WebPageURL,
        /*[in]*/ BSTR Text ) = 0;
      virtual HRESULT __stdcall raw_ModuleListUpdated (
        /*[in]*/ ClientSWCompatibilityLevels CompatibilityLevel ) = 0;
      virtual HRESULT __stdcall raw_MenuStructureUpdated (
        /*[in]*/ ClientSWCompatibilityLevels CompatibilityLevel ) = 0;
      virtual HRESULT __stdcall raw_AppCustomizationChanged ( ) = 0;

Quote:
};

thanks,
inna


Fri, 28 Oct 2005 22:07:49 GMT  
 Problems creating a valid object using CComObject<...>::CreateInstance
You need to either #import with raw_interfaces_only attribute, or
actually implement raw_XXX methods in your CSaxoConnEvents class. Those
are the ones that are pure virtual.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> > What kind of interface is it - custom, dispinterface, dual? Show the
IDL
> > definition of their interfaces and coclasses.

> here it is:

> struct __declspec(uuid("5b8023d1-7b32-11d3-9a90-00105acc135c"))
> IConnectionEvents : IUnknown
> {
>     //
>     // Wrapper methods for error-handling
>     //

>     HRESULT LogInProgress (
>         long StatusCode,
>         _bstr_t StatusText );
>     //
>     // Raw methods provided by interface
>     //

>       virtual HRESULT __stdcall raw_LogInProgress (
>         /*[in]*/ long StatusCode,
>         /*[in]*/ BSTR StatusText ) = 0;
> };



Fri, 28 Oct 2005 23:37:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Error C2065 when using CComObject<xxxx>* declaration

2. <<<<<<<Parsing help, please>>>>>>>>

3. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

4. <<<>>>Need C code advice with functions and sorting.<<<>>>

5. Reproducing CComObject<> from COM interface

6. CComObject<X>* versus X* use ?

7. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

8. >>>Windows Service<<<

9. <<Borland C/C++ 5.0 Problem >>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

10. using greater<> on an object

11. Calling CComObject<T>::CreateInstance from imported library?

12. CStatic: m_Static.Create <Text Color Problem>

 

 
Powered by phpBB® Forum Software