CoCreateInstance of VB object in debug mode 
Author Message
 CoCreateInstance of VB object in debug mode

Hi everyone, I'm building a VC++ service in ATL for win2k that needs to call
a ActiveX dll running in MTS built in Visual Basic.  For testing purposes
I've build a console application.  I've attached my code at the bottom.  The
problem I'm running into is two fold.  The first problem is that when I
create the instance of the object it spins up in MTS no problem.  But I get
nothing when I call invoke on the function.  To try to figure out what is
happening here I want to run the VB dll in debug mode in VB.  When I have it
running in VB my CoCreateInstance returns 0 and naturally the rest of the
calls fail.  Does anyone know how to call a VB component running in debug
mode?

Thanks a lot for any help/suggestions you can give.

Greg

                        HRESULT hr=1;
                        CLSID clsid;

                        CLSIDFromProgID(L"bhSMTPListener.Handler", &clsid);
                        IDispatch *pIDispatch = NULL;
                        hr = CoInitialize(NULL);
                        //hr = CoCreateInstance(clsid, NULL,
CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
                        hr = CoCreateInstance(clsid, NULL,
CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

                        DISPID dispid;
                        OLECHAR FAR* szMemberName = L"_iHandler.Receive";
                        hr = pIDispatch->GetIDsOfNames(IID_NULL,
&szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

                        DISPPARAMS dispparams;
                        dispparams.cArgs = 1;
                        dispparams.cNamedArgs = 0;
                        dispparams.rgdispidNamedArgs = NULL;
                        dispparams.rgvarg = new VARIANTARG[1];
                        dispparams.rgvarg[0].vt = VT_UNKNOWN;
                        dispparams.rgvarg[0].lVal = msgRec;
// ulong

                        VARIANTARG result;

                        result.vt = VT_BSTR;
                        result.bstrVal = SysAllocString(L"");

                        EXCEPINFO excep;                // Describing an
exception that occurred during IDispatch::Invoke

                        UINT uArgErr;

                        // Providing access to the methods and properties
exposed by the dual interface
                        hr = pIDispatch->Invoke(dispid,

IID_NULL,

LOCALE_SYSTEM_DEFAULT,

DISPATCH_METHOD,

&dispparams,

&result,

&excep,

&uArgErr);
                        hr = pIDispatch->Release();

                        CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 CoCreateInstance of VB object in debug mode
Why are there two calls to CoCreate? Once with inproc and next with local ?
That might (or might not) affect the way it behaves..  Also, can you check
the HRESULT returned by each calls ? Are any of them failing?? What is the
failed HRESULT?

--
<mvp val="vc++">
Girish Bharadwaj
</mvp>

Quote:
> Hi everyone, I'm building a VC++ service in ATL for win2k that needs to
call
> a ActiveX dll running in MTS built in Visual Basic.  For testing purposes
> I've build a console application.  I've attached my code at the bottom.
The
> problem I'm running into is two fold.  The first problem is that when I
> create the instance of the object it spins up in MTS no problem.  But I
get
> nothing when I call invoke on the function.  To try to figure out what is
> happening here I want to run the VB dll in debug mode in VB.  When I have
it
> running in VB my CoCreateInstance returns 0 and naturally the rest of the
> calls fail.  Does anyone know how to call a VB component running in debug
> mode?

> Thanks a lot for any help/suggestions you can give.

> Greg

>                         HRESULT hr=1;
>                         CLSID clsid;

>                         CLSIDFromProgID(L"bhSMTPListener.Handler",
&clsid);
>                         IDispatch *pIDispatch = NULL;
>                         hr = CoInitialize(NULL);
>                         file://hr = CoCreateInstance(clsid, NULL,
> CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
>                         hr = CoCreateInstance(clsid, NULL,
> CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

>                         DISPID dispid;
>                         OLECHAR FAR* szMemberName = L"_iHandler.Receive";
>                         hr = pIDispatch->GetIDsOfNames(IID_NULL,
> &szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

>                         DISPPARAMS dispparams;
>                         dispparams.cArgs = 1;
>                         dispparams.cNamedArgs = 0;
>                         dispparams.rgdispidNamedArgs = NULL;
>                         dispparams.rgvarg = new VARIANTARG[1];
>                         dispparams.rgvarg[0].vt = VT_UNKNOWN;
>                         dispparams.rgvarg[0].lVal = msgRec;
> // ulong

>                         VARIANTARG result;

>                         result.vt = VT_BSTR;
>                         result.bstrVal = SysAllocString(L"");

>                         EXCEPINFO excep;                // Describing an
> exception that occurred during IDispatch::Invoke

>                         UINT uArgErr;

>                         // Providing access to the methods and properties
> exposed by the dual interface
>                         hr = pIDispatch->Invoke(dispid,

> IID_NULL,

> LOCALE_SYSTEM_DEFAULT,

> DISPATCH_METHOD,

> &dispparams,

> &result,

> &excep,

> &uArgErr);
>                         hr = pIDispatch->Release();

>                         CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 CoCreateInstance of VB object in debug mode
I have two in there (one is commented out) because I was switching back and
forth between making it call in-proc and out-of-proc.  The latter is the way
it should be.

The HRESULT that I get back from the failed CoCreateInstance is 0.


Quote:
> Why are there two calls to CoCreate? Once with inproc and next with local
?
> That might (or might not) affect the way it behaves..  Also, can you check
> the HRESULT returned by each calls ? Are any of them failing?? What is the
> failed HRESULT?

> --
> <mvp val="vc++">
> Girish Bharadwaj
> </mvp>


> > Hi everyone, I'm building a VC++ service in ATL for win2k that needs to
> call
> > a ActiveX dll running in MTS built in Visual Basic.  For testing
purposes
> > I've build a console application.  I've attached my code at the bottom.
> The
> > problem I'm running into is two fold.  The first problem is that when I
> > create the instance of the object it spins up in MTS no problem.  But I
> get
> > nothing when I call invoke on the function.  To try to figure out what
is
> > happening here I want to run the VB dll in debug mode in VB.  When I
have
> it
> > running in VB my CoCreateInstance returns 0 and naturally the rest of
the
> > calls fail.  Does anyone know how to call a VB component running in
debug
> > mode?

> > Thanks a lot for any help/suggestions you can give.

> > Greg

> >                         HRESULT hr=1;
> >                         CLSID clsid;

> >                         CLSIDFromProgID(L"bhSMTPListener.Handler",
> &clsid);
> >                         IDispatch *pIDispatch = NULL;
> >                         hr = CoInitialize(NULL);
> >                         file://hr = CoCreateInstance(clsid, NULL,
> > CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
> >                         hr = CoCreateInstance(clsid, NULL,
> > CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

> >                         DISPID dispid;
> >                         OLECHAR FAR* szMemberName =

L"_iHandler.Receive";

- Show quoted text -

Quote:
> >                         hr = pIDispatch->GetIDsOfNames(IID_NULL,
> > &szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

> >                         DISPPARAMS dispparams;
> >                         dispparams.cArgs = 1;
> >                         dispparams.cNamedArgs = 0;
> >                         dispparams.rgdispidNamedArgs = NULL;
> >                         dispparams.rgvarg = new VARIANTARG[1];
> >                         dispparams.rgvarg[0].vt = VT_UNKNOWN;
> >                         dispparams.rgvarg[0].lVal = msgRec;
> > // ulong

> >                         VARIANTARG result;

> >                         result.vt = VT_BSTR;
> >                         result.bstrVal = SysAllocString(L"");

> >                         EXCEPINFO excep;                // Describing an
> > exception that occurred during IDispatch::Invoke

> >                         UINT uArgErr;

> >                         // Providing access to the methods and
properties
> > exposed by the dual interface
> >                         hr = pIDispatch->Invoke(dispid,

> > IID_NULL,

> > LOCALE_SYSTEM_DEFAULT,

> > DISPATCH_METHOD,

> > &dispparams,

> > &result,

> > &excep,

> > &uArgErr);
> >                         hr = pIDispatch->Release();

> >                         CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 CoCreateInstance of VB object in debug mode

How about the rest of the method calls? are they also returning 0 as HR?

--
<mvp val="vc++">
Girish Bharadwaj
</mvp>

Quote:
> I have two in there (one is commented out) because I was switching back
and
> forth between making it call in-proc and out-of-proc.  The latter is the
way
> it should be.

> The HRESULT that I get back from the failed CoCreateInstance is 0.



> > Why are there two calls to CoCreate? Once with inproc and next with
local
> ?
> > That might (or might not) affect the way it behaves..  Also, can you
check
> > the HRESULT returned by each calls ? Are any of them failing?? What is
the
> > failed HRESULT?

> > --
> > <mvp val="vc++">
> > Girish Bharadwaj
> > </mvp>


> > > Hi everyone, I'm building a VC++ service in ATL for win2k that needs
to
> > call
> > > a ActiveX dll running in MTS built in Visual Basic.  For testing
> purposes
> > > I've build a console application.  I've attached my code at the
bottom.
> > The
> > > problem I'm running into is two fold.  The first problem is that when
I
> > > create the instance of the object it spins up in MTS no problem.  But
I
> > get
> > > nothing when I call invoke on the function.  To try to figure out what
> is
> > > happening here I want to run the VB dll in debug mode in VB.  When I
> have
> > it
> > > running in VB my CoCreateInstance returns 0 and naturally the rest of
> the
> > > calls fail.  Does anyone know how to call a VB component running in
> debug
> > > mode?

> > > Thanks a lot for any help/suggestions you can give.

> > > Greg

> > >                         HRESULT hr=1;
> > >                         CLSID clsid;

> > >                         CLSIDFromProgID(L"bhSMTPListener.Handler",
> > &clsid);
> > >                         IDispatch *pIDispatch = NULL;
> > >                         hr = CoInitialize(NULL);
> > >                         file://hr = CoCreateInstance(clsid, NULL,
> > > CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
> > >                         hr = CoCreateInstance(clsid, NULL,
> > > CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

> > >                         DISPID dispid;
> > >                         OLECHAR FAR* szMemberName =
> L"_iHandler.Receive";
> > >                         hr = pIDispatch->GetIDsOfNames(IID_NULL,
> > > &szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

> > >                         DISPPARAMS dispparams;
> > >                         dispparams.cArgs = 1;
> > >                         dispparams.cNamedArgs = 0;
> > >                         dispparams.rgdispidNamedArgs = NULL;
> > >                         dispparams.rgvarg = new VARIANTARG[1];
> > >                         dispparams.rgvarg[0].vt = VT_UNKNOWN;
> > >                         dispparams.rgvarg[0].lVal = msgRec;
> > > // ulong

> > >                         VARIANTARG result;

> > >                         result.vt = VT_BSTR;
> > >                         result.bstrVal = SysAllocString(L"");

> > >                         EXCEPINFO excep;                // Describing
an
> > > exception that occurred during IDispatch::Invoke

> > >                         UINT uArgErr;

> > >                         // Providing access to the methods and
> properties
> > > exposed by the dual interface
> > >                         hr = pIDispatch->Invoke(dispid,

> > > IID_NULL,

> > > LOCALE_SYSTEM_DEFAULT,

> > > DISPATCH_METHOD,

> > > &dispparams,

> > > &result,

> > > &excep,

> > > &uArgErr);
> > >                         hr = pIDispatch->Release();

> > >                         CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 CoCreateInstance of VB object in debug mode
CoInitialize returns 1
CoCreateInstance returns 0
GetIDsOfNames returns -2147352570 (Unknown name.)
Invoke returns -10737418819 (No error message)
Release returns 0


Quote:
> How about the rest of the method calls? are they also returning 0 as HR?

> --
> <mvp val="vc++">
> Girish Bharadwaj
> </mvp>


> > I have two in there (one is commented out) because I was switching back
> and
> > forth between making it call in-proc and out-of-proc.  The latter is the
> way
> > it should be.

> > The HRESULT that I get back from the failed CoCreateInstance is 0.



> > > Why are there two calls to CoCreate? Once with inproc and next with
> local
> > ?
> > > That might (or might not) affect the way it behaves..  Also, can you
> check
> > > the HRESULT returned by each calls ? Are any of them failing?? What is
> the
> > > failed HRESULT?

> > > --
> > > <mvp val="vc++">
> > > Girish Bharadwaj
> > > </mvp>


> > > > Hi everyone, I'm building a VC++ service in ATL for win2k that needs
> to
> > > call
> > > > a ActiveX dll running in MTS built in Visual Basic.  For testing
> > purposes
> > > > I've build a console application.  I've attached my code at the
> bottom.
> > > The
> > > > problem I'm running into is two fold.  The first problem is that
when
> I
> > > > create the instance of the object it spins up in MTS no problem.
But
> I
> > > get
> > > > nothing when I call invoke on the function.  To try to figure out
what
> > is
> > > > happening here I want to run the VB dll in debug mode in VB.  When I
> > have
> > > it
> > > > running in VB my CoCreateInstance returns 0 and naturally the rest
of
> > the
> > > > calls fail.  Does anyone know how to call a VB component running in
> > debug
> > > > mode?

> > > > Thanks a lot for any help/suggestions you can give.

> > > > Greg

> > > >                         HRESULT hr=1;
> > > >                         CLSID clsid;

> > > >                         CLSIDFromProgID(L"bhSMTPListener.Handler",
> > > &clsid);
> > > >                         IDispatch *pIDispatch = NULL;
> > > >                         hr = CoInitialize(NULL);
> > > >                         file://hr = CoCreateInstance(clsid, NULL,
> > > > CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
> > > >                         hr = CoCreateInstance(clsid, NULL,
> > > > CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

> > > >                         DISPID dispid;
> > > >                         OLECHAR FAR* szMemberName =
> > L"_iHandler.Receive";
> > > >                         hr = pIDispatch->GetIDsOfNames(IID_NULL,
> > > > &szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

> > > >                         DISPPARAMS dispparams;
> > > >                         dispparams.cArgs = 1;
> > > >                         dispparams.cNamedArgs = 0;
> > > >                         dispparams.rgdispidNamedArgs = NULL;
> > > >                         dispparams.rgvarg = new VARIANTARG[1];
> > > >                         dispparams.rgvarg[0].vt = VT_UNKNOWN;
> > > >                         dispparams.rgvarg[0].lVal = msgRec;
> > > > // ulong

> > > >                         VARIANTARG result;

> > > >                         result.vt = VT_BSTR;
> > > >                         result.bstrVal = SysAllocString(L"");

> > > >                         EXCEPINFO excep;                //
Describing
> an
> > > > exception that occurred during IDispatch::Invoke

> > > >                         UINT uArgErr;

> > > >                         // Providing access to the methods and
> > properties
> > > > exposed by the dual interface
> > > >                         hr = pIDispatch->Invoke(dispid,

> > > > IID_NULL,

> > > > LOCALE_SYSTEM_DEFAULT,

> > > > DISPATCH_METHOD,

> > > > &dispparams,

> > > > &result,

> > > > &excep,

> > > > &uArgErr);
> > > >                         hr = pIDispatch->Release();

> > > >                         CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 CoCreateInstance of VB object in debug mode
The method name is wrong. Perhaps it should be only "Receive"?
It definitely shouldn't include any object reference...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> CoInitialize returns 1
> CoCreateInstance returns 0
> GetIDsOfNames returns -2147352570 (Unknown name.)
> Invoke returns -10737418819 (No error message)
> Release returns 0



> > How about the rest of the method calls? are they also returning 0 as HR?

> > --
> > <mvp val="vc++">
> > Girish Bharadwaj
> > </mvp>


> > > I have two in there (one is commented out) because I was switching
back
> > and
> > > forth between making it call in-proc and out-of-proc.  The latter is
the
> > way
> > > it should be.

> > > The HRESULT that I get back from the failed CoCreateInstance is 0.



> > > > Why are there two calls to CoCreate? Once with inproc and next with
> > local
> > > ?
> > > > That might (or might not) affect the way it behaves..  Also, can you
> > check
> > > > the HRESULT returned by each calls ? Are any of them failing?? What
is
> > the
> > > > failed HRESULT?

> > > > --
> > > > <mvp val="vc++">
> > > > Girish Bharadwaj
> > > > </mvp>


> > > > > Hi everyone, I'm building a VC++ service in ATL for win2k that
needs
> > to
> > > > call
> > > > > a ActiveX dll running in MTS built in Visual Basic.  For testing
> > > purposes
> > > > > I've build a console application.  I've attached my code at the
> > bottom.
> > > > The
> > > > > problem I'm running into is two fold.  The first problem is that
> when
> > I
> > > > > create the instance of the object it spins up in MTS no problem.
> But
> > I
> > > > get
> > > > > nothing when I call invoke on the function.  To try to figure out
> what
> > > is
> > > > > happening here I want to run the VB dll in debug mode in VB.  When
I
> > > have
> > > > it
> > > > > running in VB my CoCreateInstance returns 0 and naturally the rest
> of
> > > the
> > > > > calls fail.  Does anyone know how to call a VB component running
in
> > > debug
> > > > > mode?

> > > > > Thanks a lot for any help/suggestions you can give.

> > > > > Greg

> > > > >                         HRESULT hr=1;
> > > > >                         CLSID clsid;

> > > > >                         CLSIDFromProgID(L"bhSMTPListener.Handler",
> > > > &clsid);
> > > > >                         IDispatch *pIDispatch = NULL;
> > > > >                         hr = CoInitialize(NULL);
> > > > >                         file://hr = CoCreateInstance(clsid, NULL,
> > > > > CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch);
> > > > >                         hr = CoCreateInstance(clsid, NULL,
> > > > > CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pIDispatch);

> > > > >                         DISPID dispid;
> > > > >                         OLECHAR FAR* szMemberName =
> > > L"_iHandler.Receive";
> > > > >                         hr = pIDispatch->GetIDsOfNames(IID_NULL,
> > > > > &szMemberName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);

> > > > >                         DISPPARAMS dispparams;
> > > > >                         dispparams.cArgs = 1;
> > > > >                         dispparams.cNamedArgs = 0;
> > > > >                         dispparams.rgdispidNamedArgs = NULL;
> > > > >                         dispparams.rgvarg = new VARIANTARG[1];
> > > > >                         dispparams.rgvarg[0].vt = VT_UNKNOWN;
> > > > >                         dispparams.rgvarg[0].lVal = msgRec;
> > > > > // ulong

> > > > >                         VARIANTARG result;

> > > > >                         result.vt = VT_BSTR;
> > > > >                         result.bstrVal = SysAllocString(L"");

> > > > >                         EXCEPINFO excep;                //
> Describing
> > an
> > > > > exception that occurred during IDispatch::Invoke

> > > > >                         UINT uArgErr;

> > > > >                         // Providing access to the methods and
> > > properties
> > > > > exposed by the dual interface
> > > > >                         hr = pIDispatch->Invoke(dispid,

> > > > > IID_NULL,

> > > > > LOCALE_SYSTEM_DEFAULT,

> > > > > DISPATCH_METHOD,

> > > > > &dispparams,

> > > > > &result,

> > > > > &excep,

> > > > > &uArgErr);
> > > > >                         hr = pIDispatch->Release();

> > > > >                         CoUninitialize();



Sun, 03 Nov 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. CoCreateInstance of VB object in debug mode

2. CoCreateInstance of VB object in debug mode

3. ATL ConnectionPoint fails in VB debug Mode

4. Debugging an internet enabled application when session object is in async mode

5. Problem debugging VB COM object from a ATL-Service

6. HELP: Debugging a COM automation DLL object in VB

7. Works in Debug mode but not in Release mode

8. MIDL compiler fails during release mode but works fine in debug mode

9. Works in Debug Mode crahses in Release Mode

10. Run time Release mode error but no Debug mode error

11. VC 5.0 Relase Mode & Debug Mode problem

12. Quiet NaNs, release mode and debug mode

 

 
Powered by phpBB® Forum Software