title: Correct Way to Load Assembly, Find Class and Call Run() Method
body: <p>Sample console program.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          // ... code to build dll ... not written yet ...
          Assembly assembly = Assembly.LoadFile(@"C:\dyn.dll");
          // don't know what or how to cast here
          // looking for a better way to do next 3 lines
          IRunnable r = assembly.CreateInstance("TestRunner");
          if (r == null) throw new Exception("broke");
          r.Run();
  
      }
  }
  </code></pre>
  
  <p>I want to dynamically build an assembly (.dll), and then load the assembly, instantiate a class, and call the Run() method of that class. Should I try casting the TestRunner class to something? Not sure how the types in one assembly (dynamic code) would know about my types in my (static assembly / shell app). Is it better to just use a few lines of reflection code to call Run() on just an object? What should that code look like?</p>
  
  <p>UPDATE:
  William Edmondson - see comment</p>