OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Ben Callister (BCallisterTUTOR.COM)
Date: Tue Jun 19 2001 - 21:39:48 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Hello:

    i have the following situation:
    1) a vc++ out-of-proc component that receives a idispatch pointer to a vb
    com object residing in a vb dll.
    2) the vc++ component does some work and then performs a callback into the
    vb com object (via IDispatch::Invoke()).
    3) when Invoke() is called, i get the error:
       - -2147024809 (The parameter is incorrect.)

    note that the m_pSink->GetIDsOfNames() method succeedes. does anyone know
    why this might be? below is the vb function as well as the vc++ calling
    function.
    thanks for any help and/or suggestions,
    Ben

    =======================================================
    = VB FUNCTION...
    =======================================================

    Public Sub MyCallback(theResults As Variant)
        On Error GoTo errHandler

        MsgBox "RESULTS: " & theResults & ""
        Exit Sub

    errHandler:
        MsgBox Error$(Err)
        Exit Sub
    End Sub

    =======================================================
    = VC++ FUNCTION...
    =======================================================

    void
    EventMarshaller::TriggerEvent
    (
     BSTR bCallbackMethodName,
     VARIANT* vData
    )
    {
     //make sure that we have a registered sink object
     if (!m_pSink)
      return;

     m_Lock.Lock();

      OLECHAR FAR* szMember = bCallbackMethodName;
      DISPID dispid;

      //build up paraters to pass to Invoke() call
      VARIANTARG vArg;
      ::VariantInit(&vArg);
      vArg.vt = VT_VARIANT;
      vArg.pvarVal = vData;

      DISPPARAMS dispparams;
      dispparams.cArgs = 1;
      dispparams.rgvarg = &vArg;
      dispparams.cNamedArgs = 0;
      dispparams.rgdispidNamedArgs = NULL;

      //get the dispID for the function that we want to run on the passed
    interface
      HRESULT hr;
      hr = m_pSink->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT,
    &dispid);
      if (FAILED(hr))
       throw exception("Error, unable to retrieve dispid for EventCallback()
    method on registered sink object.");

      //now invoke the task method on the passed interface
      hr = m_pSink->Invoke(
           dispid,
           IID_NULL,
           LOCALE_USER_DEFAULT,
           DISPATCH_METHOD,
           &dispparams, NULL, NULL, NULL);
      if (FAILED(hr))
       throw exception("Error, unable to call specified method on specified
    callback object.");

     m_Lock.UnLock();
     return;
    }

    Benjamin Callister
    Vice President of Engineering
    Tutor.com
    Real Tutors. Real Results.

    e: bcallistertutor.com
    p: 212.528.3101; x.227
    w: http://www.tutor.com <http://www.tutor.com/>

    ----------------------------------------------------------------
    Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM