title: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type
body: <p>Having done nothing more than install Visual Studio 2012, our existing application now crashes when attempting to create a delegate.  </p>
  
  <p>Why would we be getting this error when running our application (not running in debug...just running the .exe normally...not having re-compiled, or done anything other than install Visual Studio 2012)?</p>
  
  <p>Does Visual Studio 2012 update .net 4.0 WindowsFormsIntegration in some way?</p>
  
  <p>Any suggestions on how to get around this?</p>
  
  <blockquote>
    <p>'The invocation of the constructor on type 'MyWindowsFormsHost' that matches the
    specified binding constraints threw an exception.'</p>
  </blockquote>
  
  <p>With internal exception:</p>
  
  <blockquote>
    <p>Cannot bind to the target method because its signature or security
    transparency is not compatible with that of the delegate type</p>
  </blockquote>
  
  <p>The offending class and line:</p>
  
  <pre><code>internal class MyWindowsFormsHost : WindowsFormsHost
  {
      private delegate void NotifyChildFocus(ref Message m);
      private readonly NotifyChildFocus childGotFocus;
  
      public MyWindowsFormsHost()
      {
           //this line crashes now (and did not before VS2012 install)
           this.childGotFocus = Delegate.CreateDelegate(typeof(NotifyChildFocus),
                                   this, "NotifyActivateApp") as NotifyChildFocus;
      }
  }
  </code></pre>
  
  <p>UPDATE: Discovered that the NotifyActiveateApp method no longer exists on WindowsFormsHost.  What I don't understand is how installing .net 4.5 with visual studio 2012 has affected my existing 4.0 application.</p>
  
  <p>UPDATE: In order to get around this, I've used reflection to check if the NotifyActivateApp method exists.  (If it doesn't exist, then the app is running in the patched .net version...and I don't have to worry about the activation bug this child focus code was written to fix).  </p>
  
  <pre><code>    MethodInfo methodInfo = (typeof(WindowsFormsHost)).GetMethod("NotifyActivateApp", BindingFlags.NonPublic | BindingFlags.Instance);
  if (methodInfo != null)
  {
       this.childGotFocus = Delegate.CreateDelegate(typeof(NotifyChildFocus), this, "NotifyActivateApp") as NotifyChildFocus;
  }
  </code></pre>
  
  <p>Note to Microsoft: Thanks for fixing your bug...I just wish you would have rolled it out in a way that didn't break existing code.</p>