title: Loading MailKit DLL as Assembly in Powershell
body: <p>I'm trying to use MailKit dll as assembly in Powershell but there is no way it works.
  I've tried with add-type and  with [System.Reflection.Assembly] methods bwithout success.
  The link to mailkit library: </p>
  
  <p><a href="https://github.com/jstedfast/MailKit" rel="nofollow noreferrer">https://github.com/jstedfast/MailKit</a></p>
  
  <p>With this method : </p>
  
  <pre><code> $path="$HOME\.nuget\packages\mailkit\1.16.1\lib\net451\MailKit.dll" 
    [System.Reflection.Assembly]::LoadFile($path)
  </code></pre>
  
  <p>ther isn't reference to the assembly in memory.
  With this method :</p>
  
  <pre><code>Add-Type -Path $path
  </code></pre>
  
  <p>this is the error:</p>
  
  <blockquote>
    <ul>
    <li>Add-Type -Path $path</li>
    <li>~~~~~~~~~~~~~~~~~~~~
    
    <ul>
    <li>CategoryInfo          : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException</li>
    <li>FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>Thanks</p>
  
  <p>Daniele</p>