Type mismatch error MyFunc(arg1), MyFunc is out-of-proc COM and arg1 is IUnknown**

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GuyHarel
    New Member
    • Feb 2009
    • 4

    Type mismatch error MyFunc(arg1), MyFunc is out-of-proc COM and arg1 is IUnknown**

    Hello
    I am trying to interface with a legacy MFC out-of-proc COM server. Some by ref arguments work fine (like long*) the other (IUnknown**) give me a DISP_E_TYPEMISM ATCH, no matter what I try. Example:

    COM server:
    Code:
    long CNAVDocViewer::getMainWindowHandle(long* _plhWnd)
    VB.NET:
    Code:
    Dim o As Object = CreateObject("NAVDocViewer.NAVDocViewer")
    Dim h As Integer = Integer.MinValue
    o.getMainWindowHandle(h)
    Works...getting the right value, however:

    COM server:
    Code:
    long CNAVDocViewer::closeAllDocument(IUnknown**	_ppitfEreur)
    VB.NET
    (I've tried all the following types, none works)
    Code:
            ' DISP_E_TYPEMISMATCH
            Dim err As Object = Nothing ' No
            Dim errDQS As aDQSErrorServr.DQSEror = New aDQSErrorServr.DQSEror ' No
            Dim errDQSI As aDQSErrorServr.IDQSEror = Nothing ' No
            Dim i As Int32 = 0 ' No
            Dim s As String = "" ' No... :)
            Dim p As IntPtr = Nothing ' No
            Dim p1 As IntPtr = New IntPtr(0) ' No
            Dim p2 As IntPtr = Marshal.GetIUnknownForObject(errDQS)  ' No
    
            o.closeAllDocument(errDQSI)
    The value returned by the COM server is NULL if no error happened in the function, otherwise a DQSERROR COM object.
    I spend two days reading articles on this and IntPtr should do the job, followed by Marshal.QueryIn terafce() but it does now work.

    Any help would be appreciated. Tx.
  • GuyHarel
    New Member
    • Feb 2009
    • 4

    #2
    Solved by the MSDN guys:
    The home for technical questions and answers at Microsoft. Get started asking, answering, and browsing questions about products like .Net, Azure, or Teams.

    Comment

    Working...