title: VB.net Marshalling Error
body: <p>I have to create an array of structure type in VB.net. but I am getting error while marshalling this error. I have to pass this array of structure type in to Dll function.</p>
  
  <p>Code:
  Structure declaration:</p>
  
  <pre><code>&lt;StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)&gt; _
      Public Structure dx_entry
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=10)&gt; _
          Public dx As String
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=3)&gt; _
          Public type As String
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)&gt; _
          Public narray As String
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)&gt; _
          Public ctier As String
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)&gt; _
          Public poa As String
          &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)&gt; _
          Public poa_rsvd As String
         &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=81)&gt; _
          Public filler As String
      End Structure
  </code></pre>
  
  <p>Code of initiallization and marshalling:</p>
  
  <pre><code>Dim stpDx(2) As dx_entry
  stpDx(1).dx = "5939" &amp; Space(6)
          stpDx(1).type = "BK" &amp; Space(1)
          stpDx(1).narray = Space(1)
          stpDx(1).ctier = Space(1)
          stpDx(1).poa = "Y"
          stpDx(1).poa_rsvd = Space(1)
          stpDx(1).filler = Space(81)
          stpDx(2).dx = "1231" &amp; Space(6)
          stpDx(2).type = "BF" &amp; Space(1)
          stpDx(2).narray = Space(1)
          stpDx(2).ctier = Space(1)
          stpDx(2).poa = "Y"
          stpDx(2).poa_rsvd = Space(1)
          stpDx(2).filler = Space(81)
          Dim pDxBuf As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(stpDx))
          Marshal.StructureToPtr(stpDx, pDxBuf, False)
          ezg_Block.pDx = pDxBuf
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>An unhandled exception of type 'System.ArgumentException' occurred in Audit_Demo_2307.exe
  </code></pre>
  
  <p>Additional information: Type dx_entry[] can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.</p>