COM Interoperability RRS feed

  • Question

  • Getting DISP_E_TYPEMISMATCH error

    -net framework

    Getting DISP_E_TYPEMISMATCH error

    Hi I am getting DISP_E_TYPEMISMATCH while calling a VC++ COM method from C#
    winform client.

    .Net signature
    Amtui.ICSRequestServerClass.GetOtherInsureds(int ModelHandle, int InsuredNumberI, ref int OtherInsuredI, ref int InsuredTypeI, ref int NewGIR, ref int NewADB, ref int NewLTC, ref int NewEBR, ref int NewDI2, ref int NewDI5, ref int NewOIR)



    COM signature
    short CRequestServer::GetOtherInsureds(long TopLevelHandle, int
    InsuredNumberI, long FAR* OtherInsuredI, int FAR* iInsuredTypeI, long FAR*
    NewGIR,long FAR* NewADB, long FAR* NewLTC, long FAR* NewEBR, long FAR*
    NewDI2, long FAR* NewDI5, long FAR* NewOIR)






    iResult = m_objRequestServer.GetOtherInsureds(m_iToplevelHandle, iIndex, ref hOtherInsured, ref iOtherInsuredNo,

    ref hGIR, ref hADB, ref hLTC, ref hEBR, ref hDIR2Yr, ref hDIR5Yr, ref hOIR);


    catch (Exception objEx)





    Here it is catching exception

    {System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

    Any help will be appreciated.

    Thanks and regards



    Friday, November 30, 2007 5:53 AM


  • The COM side expect some pointers as it's argument, you should use unsafe pointer or Intptr to pass to it.

    And I suggest you can check out the  Marshal.AllocHGlobal Method to Allocates a block of memory and  pass the memory to the unmanged side. Remember to  release the memory using the 
    Marshal.FreeHGlobal Method.
    Monday, December 3, 2007 6:26 AM