title: Dispatch not hooked to windows memory
body: <p>Sometimes I get an error (exception):</p>
  
  <pre><code>java.lang.IllegalStateException: Dispatch not hooked to windows memory
  </code></pre>
  
  <p>What does it mean? How to prevent it?</p>
  
  <p>This is a sample code that results in this error:</p>
  
  <pre><code>import com.jacob.activeX.*;
  import com.jacob.com.*;
  
  public class Hooked {
  
    public static void main(String[] args) {
      ActiveXComponent e = new ActiveXComponent("Excel.Application");
      ActiveXComponent sh = new ActiveXComponent(
        e.getProperty("ActiveSheet").toDispatch());
      System.out.println(sh.getPropertyAsString("Name"));
    }
  
  }
  </code></pre>