title: Issue converting C# marshal interface code to VB.NET
body: <p>I'm attempting to convert a project from C# to VB.NET to enable drag and dropping of Outlook messages into our program. </p>
  
  <p>The original source can be found <a href="https://www.codeproject.com/Articles/28209/Outlook-Drag-and-Drop-in-C?fid=1524694" rel="nofollow noreferrer">here</a> on CodeProject. </p>
  
  <p>I'm 95% of the way there but having trouble implementing the IStorage interface , a portion of which is outlined below.</p>
  
  <pre class="lang-c# prettyprint-override"><code>public interface IStorage
  {
      [return: MarshalAs(UnmanagedType.Interface)]
      IStream CreateStream([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                           [In, MarshalAs(UnmanagedType.U4)] int grfMode,
                           [In, MarshalAs(UnmanagedType.U4)] int reserved1,
                           [In, MarshalAs(UnmanagedType.U4)] int reserved2);                
  }
  </code></pre>
  
  <p>I've converted it to the following in VB.NET:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;MarshalAs(UnmanagedType.Interface)&gt;
  Function CreateStream(&lt;[In], MarshalAs(UnmanagedType.BStr)&gt; ByVal pwcsName As String,
                        &lt;[In], MarshalAs(UnmanagedType.U4)&gt; ByVal grfMode As Integer,
                        &lt;[In], MarshalAs(UnmanagedType.U4)&gt; ByVal reserved1 As Integer,
                        &lt;[In], MarshalAs(UnmanagedType.U4)&gt; ByVal reserved2 As Integer) As IStream
  </code></pre>
  
  <p>However, it results in the following error:</p>
  
  <blockquote>
    <p>Attribue 'MarshalAsAttribute' cannot be applied to 'CreateStream' because the attribute is not valid on this declaration type.</p>
  </blockquote>
  
  <p>I'm a little out of my depth here and would really appreciate any <em>pointers</em> you may have in helping me solve this issue. </p>
  
  <p>Many thanks.</p>