title: "cannot create instance defined in assembly" when creating a new System.Drawing.Icon
body: <p>I am trying to create a system tray icon in WPF using the lines of code below:</p>
  
  <pre><code>System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
  ni.Icon = new System.Drawing.Icon("main.ico");
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&gt; &lt;Window x:Class="WpfExample.Window1"
  &gt;     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  &gt;     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  &gt;     Title="Window1" Height="300" Width="300"&gt;
  &gt;     &lt;Grid&gt;
  &gt;         &lt;Button Height="23" Margin="103,0,100,100" Name="button1"
  &gt; VerticalAlignment="Bottom"&gt;Submit&lt;/Button&gt;
  &gt;         &lt;TextBox Height="23" Margin="77,75,81,0" Name="textBox1"
  &gt; VerticalAlignment="Top" /&gt;
  &gt;     &lt;/Grid&gt; &lt;/Window&gt;
  </code></pre>
  
  <p>I've searched for a solution on Google but I'm trying to learn WPF and this is a problem I have hit when creating a system tray icon. The message I get is shown below:</p>
  
  <blockquote>
    <p>Cannot create instance of 'Window1'
    defined in assembly 'WpfExample,
    Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null'. Exception has
    been thrown by the target of an
    invocation.  Error in markup file
    'Window1.xaml' Line 1 Position 9.</p>
  </blockquote>
  
  <p>Can anyone point me in the right direction?</p>