title: Powershell add type in class in PSM1
body: <p>In a PS1, this works</p>
  
  <pre><code>class pxInitFailureMessage {
      static [void] Send ([int32]$processID, [String]$title, [string]$message) {
          Add-Type -AssemblyName:System.Windows.Forms
          Add-Type -AssemblyName:System.Drawing
          $balloonTip = New-Object System.Windows.Forms.NotifyIcon
          $balloonTip.icon = [system.drawing.icon]::ExtractAssociatedIcon($(Get-Process -id:$processID | Select-Object -expandProperty:Path))
          $balloonTip.balloonTipIcon = 'Error'
          $balloonTip.balloonTipTitle = $title
          $balloonTip.balloonTipText = $message
          $balloonTip.visible = $true 
          $balloonTip.ShowBalloonTip(0)
          $balloonTip.Dispose
      }
  }
  [pxInitFailureMessage]::Send($pid, 'Title', 'Message is just some extra text')
  </code></pre>
  
  <p>But, move that class to a library.PSM1 file, and this in the PS1</p>
  
  <pre><code>Using module '\\Mac\iCloud Drive\Px Tools 4.#\Dev 4.0\#Spikes\Windows7\library.psm1'
  [pxInitFailureMessage]::Send($pid, 'Title', 'Message is just some extra text')
  </code></pre>
  
  <p>And it works in the ISE, but not in the console when run from a shortcut. I get <code>Unable to find type [system.drawing.icon].</code></p>
  
  <p>Obviously the first Add-Type works, I get no error at New-Object. So why is the second type load failing? I also tried moving the two Add-Type lines out of the class, and into the root of the module file, with the same results. What DOES work is adding those lines to the PS1, between <code>using module</code> (which has to be the first non remarked line) and the call. That works, but then you don't have a self contained class, which seems to suck a bit. What am I misunderstanding here?</p>
  
  <p>How does one make a self contained class that uses .NET types and work with it from  a module file?</p>