title: Creating an instance of a COM interop class
body: <p>I am trying to open CorelDRAW from within my program using C#. So far I have been able to do so by referencing the appropriate com library and calling</p>
  
  <pre><code>CorelDRAW.Application draw = new CorelDRAW.Application();
  draw.Visible = true; 
  </code></pre>
  
  <p>However, I would like my program to work with any version of CorelDRAW that supports interop. I am attempting to use reflection to load the interop library at runtime, where the specific dll can be chosen for the correct version. From looking around I have tried the following.</p>
  
  <pre><code>string path = "Interop.CorelDRAW.dll";
  Assembly u = Assembly.LoadFile(path);
  Type testType = u.GetType("CorelDRAW.Application");
  
  if (testType != null)
  {
      object draw = u.CreateInstance("CorelDRAW.Application");
  
      FieldInfo fi = testType.GetField("Visible");
      fi.SetValue(draw, true);
  }
  </code></pre>
  
  <p>The program fails at <code>u.CreateInstance...</code> fails because <code>CorelDRAW.Application</code> is an interface, not a class. I have also tried replacing <code>CorelDRAW.Application</code> with <code>CorelDRAW.ApplicationClass</code> as that is available when I browse through Interop.CorelDRAW as a resource, but then <code>u.getType...</code> fails.</p>
  
  <p>How can I get this to work? Thank you!</p>