title: .NET 4.0 - AccessViolationException and WndProc
body: <p>I have this code snippet:</p>
  
  <pre><code>internal class MTool : NativeWindow
  {
      private const int WM_LBUTTONDOWN = 0x0201;
      public event TipDeactivateEventHandler Deactivate;
  
      protected override void WndProc(ref System.Windows.Forms.Message m)
      {           
          if( m.Msg == WM_LBUTTONDOWN )
          {
              if( this.Deactivate != null)
              {
                  this.Deactivate();
              }
          }
  
          base.WndProc(ref m);
      }
  }
  </code></pre>
  
  <p>When I run my program I get an AccessViolationException error at the line <code>base.WndProc(ref m);</code> and I don't know why.</p>
  
  <p>Apparently this was ported over from .NET 2.0 to 4.0 and my theory is that there may be an alternate method used now in place of overriding WndProc. Is this case? If not why am I getting this exception?</p>