Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Marshal vs2005 problem please help

Marshal vs2005 problem please help

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    carl_sti
    wrote on last edited by
    #1

    Cannot marshal field 'table' of type 'MIB_TCPTABLE': Invalid managed/unmanaged type combination (Arrays fields must be paired with ByValArray or SafeArray). i got this error when trying to call function GetTcpTable.. see the following code.. [module declaration] Structure MIB_TCPROW Dim dwState As Long Dim dwLocalAddr As Long Dim dwLocalPort As Long Dim dwRemoteAddr As Long Dim dwRemotePort As Long End Structure Structure MIB_TCPTABLE Dim table() As MIB_TCPROW Dim dwNumEntries As Long End Structure Public v_MIB_TCPTABLE As MIB_TCPTABLE Declare Function GetTcpTable Lib "IPhlpAPI.dll" (ByVal pTcpTable As MIB_TCPTABLE, ByVal pdwSize As Long, ByVal bOrder As Long) As Long [form code] Dim tcpt As MIB_TCPTABLE Dim l As Long Dim x As Integer Dim i As Integer Dim RemA As String Dim LocP As String Dim RemP As String Dim state As Integer l = Len(v_MIB_TCPTABLE) GetTcpTable(tcpt, l, 0) x = tcpt.dwNumEntries after calling GetTcpTable function i got exeption as mention above please help

    D 1 Reply Last reply
    0
    • C carl_sti

      Cannot marshal field 'table' of type 'MIB_TCPTABLE': Invalid managed/unmanaged type combination (Arrays fields must be paired with ByValArray or SafeArray). i got this error when trying to call function GetTcpTable.. see the following code.. [module declaration] Structure MIB_TCPROW Dim dwState As Long Dim dwLocalAddr As Long Dim dwLocalPort As Long Dim dwRemoteAddr As Long Dim dwRemotePort As Long End Structure Structure MIB_TCPTABLE Dim table() As MIB_TCPROW Dim dwNumEntries As Long End Structure Public v_MIB_TCPTABLE As MIB_TCPTABLE Declare Function GetTcpTable Lib "IPhlpAPI.dll" (ByVal pTcpTable As MIB_TCPTABLE, ByVal pdwSize As Long, ByVal bOrder As Long) As Long [form code] Dim tcpt As MIB_TCPTABLE Dim l As Long Dim x As Integer Dim i As Integer Dim RemA As String Dim LocP As String Dim RemP As String Dim state As Integer l = Len(v_MIB_TCPTABLE) GetTcpTable(tcpt, l, 0) x = tcpt.dwNumEntries after calling GetTcpTable function i got exeption as mention above please help

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It looks like you've found and are using an old VB6 definition of the structures, not compatibile with VB.NET. A 32-bit integer is called Integer in VB.NET, not Long. That was the old VB6 name for it. Long under VB.NET is a 64-bit integer. If you don't get this correct, you can imbalence the call stack. The function declaration should be this:

      Declare Function Auto GetTcpTable Lib "IPhlpAPI.dll" ( _
      ByVal pTcpTable As MIB_TCPTABLE, _
      ByVal pdwSize As Integer, _
      ByVal bOrder As Boolean) As Integer

      Dave Kreskowiak Microsoft MVP - Visual Basic

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups