title: WebBrowser control external scripting doesn't work
body: <p>This is the HTML, which is stored in a string resource:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;script&gt;
             (function(){
                 window.external.hello()
             })()
          &lt;/script&gt;
      &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the contents of Form1.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace JSIE
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
  
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              webBrowser1.Navigate("about:blank");
              webBrowser1.Document.Write(String.Empty);
              webBrowser1.Document.Write(Properties.Resources.DDocument);
              webBrowser1.ObjectForScripting = new JSCallbacks();
          }
      }
  }
  </code></pre>
  
  <p>and this is JSCallbacks.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Permissions;
  using System.Runtime.InteropServices;
  using System.Windows.Forms;
  
  namespace JSIE
  {
      [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
      [ComVisible(true)]
  
      public class JSCallbacks
      {
          public void hello() {
              MessageBox.Show("Hello, world!");
          }
      }
  }
  </code></pre>
  
  <p>When I run this, it can't access the <code>hello()</code> method in the JavaScript <code>window.external</code> object, and gives me a script error message box. I have tried using <code>this</code> as the <code>ObjectForScripting</code>, but it doesn't work either.</p>