none
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) RRS feed

  • Question

  • I'm having an issue with calling a function contained in a VB6 DLL that is being called from a .Net webapp. The exception that is getting thrown is:
    Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
    The call that fails is:
    oRS = Session("DocMan").rsFolderDocuments(folderKey, sortExpression, startIndex, pageSize)
    The function that it is calling is defined as:
    Public Function rsFolderDocuments(pFolderKey As String, pSortExpression As String, pStartIndex As Integer, pPageSize As Integer) As Object
    And I've verified via output/debugging that the values being passed in are (respectively): System.String, System.String, System.Int32, System.Int32

    Does anyone have any ideas on what is going on?
    Thursday, June 11, 2009 8:31 PM

Answers

  • The error you get indicates you are making a late-bound call.  The compiler cannot provide the expected parameter types.  Assuming your signature of the rsFolderDocuments is correct, you should probably pass a short for pStartIndex and pPageSize.  VB6 Integers are 16 bits.

    You can avoid these kind of mishaps by making early-bound calls.  It is a lot faster too.  Import the type library, usually done with either TlbImp.exe or by adding a COM reference.

    Hans Passant.
    Thursday, June 11, 2009 9:09 PM
    Moderator

All replies

  • The error you get indicates you are making a late-bound call.  The compiler cannot provide the expected parameter types.  Assuming your signature of the rsFolderDocuments is correct, you should probably pass a short for pStartIndex and pPageSize.  VB6 Integers are 16 bits.

    You can avoid these kind of mishaps by making early-bound calls.  It is a lot faster too.  Import the type library, usually done with either TlbImp.exe or by adding a COM reference.

    Hans Passant.
    Thursday, June 11, 2009 9:09 PM
    Moderator
  • Good call, I must have had a brain fart and forgotten that VB6 Integers are only 16 bit...thanks for the help with an obvious answer :)
    Monday, June 15, 2009 6:22 PM