title: How to check the base type of a c# console application?
body: <p>I have several small console applications that inherit from a common <code>BaseExe</code>. Independently each works correctly as expected. I need to provide access to these applications via a central location for execution. </p>
  
  <p>My idea is to this a small web-application that provides users a list of all available exe's that can be executed. At present, I am using the <code>web.config</code> file to define my options. I however, want this to be more dynamic since this list will be growing. I thought that one can maybe use reflection to determine the type of the executable from the server directory and based on what is available, generate the list from these. At minimum, the information I need for generating this list is </p>
  
  <ol>
  <li>The path of the exe (which I have)</li>
  <li>The Name and Description (which is what I need to get)</li>
  </ol>
  
  <p>All exe's have the same dependencies and are located in the same server directory.</p>
  
  <p>In effect, my attempt has been to</p>
  
  <ul>
  <li>Get a list of exe's from the server directory</li>
  <li>check the type of each exe using <code>Assembly.LoadFile</code></li>
  <li>get the <code>Name</code> and <code>Description</code> values for the exe</li>
  </ul>
  
  <p>I can somehow get around the second step in that I can check the result of <code>GetReferencedAssemblies</code> contains the assembly of the <code>BaseExe</code> type. However, the last part completely evades me.</p>
  
  <pre><code>var path = @"C:\Code\ESG Server\ExeOutput\bin\debug";
  string[] filePaths = Directory.GetFiles(path, "*.exe");
  
  foreach (var exeReport in filePaths)
  {
      Assembly exe = Assembly.LoadFile(exeReport);
      var exeType = exe.GetType();
      var referencedAssemblies = exe.GetReferencedAssemblies();   
  }
  </code></pre>
  
  <p>How do check the base type of c# console applications? </p>
  
  <p><em><strong>Simplified exes</em></strong></p>
  
  <pre><code>public class exe1 : BaseExe
  {
      public exe1 ()
      {
          this.Name = "exe1";
          this.Description = "exe1";
      }
  
      static void Main(string[] args){  
         var exe1 = new exe1();
         /* snip */
      }
  }
  
  public class exe2 : BaseExe
  {
      public exe2 ()
      {
          this.Name = "exe2";
          this.Description = "exe2";
      }
  
      static void Main(string[] args){  
         var exe2 = new exe2();
         /* snip */
      }
  }
  </code></pre>
  
  <p>Edit: I just realized after type all of this that the <code>Name</code> and <code>Description</code> properties are set in the constructor. My current approach will not work. I am going to look into custom attributes as an alternative and use this to hold the information.  The requirement still remains the same.</p>