By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

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

P: 4
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_TYPEMISMATCH, no matter what I try. Example:

COM server:
Expand|Select|Wrap|Line Numbers
  1. long CNAVDocViewer::getMainWindowHandle(long* _plhWnd)
  2.  
VB.NET:
Expand|Select|Wrap|Line Numbers
  1. Dim o As Object = CreateObject("NAVDocViewer.NAVDocViewer")
  2. Dim h As Integer = Integer.MinValue
  3. o.getMainWindowHandle(h)
  4.  
Works...getting the right value, however:

COM server:
Expand|Select|Wrap|Line Numbers
  1. long CNAVDocViewer::closeAllDocument(IUnknown**    _ppitfEreur)
  2.  
VB.NET
(I've tried all the following types, none works)
Expand|Select|Wrap|Line Numbers
  1.         ' DISP_E_TYPEMISMATCH
  2.         Dim err As Object = Nothing ' No
  3.         Dim errDQS As aDQSErrorServr.DQSEror = New aDQSErrorServr.DQSEror ' No
  4.         Dim errDQSI As aDQSErrorServr.IDQSEror = Nothing ' No
  5.         Dim i As Int32 = 0 ' No
  6.         Dim s As String = "" ' No... :)
  7.         Dim p As IntPtr = Nothing ' No
  8.         Dim p1 As IntPtr = New IntPtr(0) ' No
  9.         Dim p2 As IntPtr = Marshal.GetIUnknownForObject(errDQS)  ' No
  10.  
  11.         o.closeAllDocument(errDQSI)
  12.  
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.QueryInterafce() but it does now work.

Any help would be appreciated. Tx.
Apr 19 '12 #1
Share this Question
Share on Google+
1 Reply


P: 4

Post your reply

Sign in to post your reply or Sign up for a free account.