title: Accessing a delegate via reflection declared outside of any class?
body: <p>I am trying a demo for reflection. The assembly I want to reflect in this class goes something like this </p>
  
  <pre><code>namespace DelegatesSampleApplication
  {
      delegate  bool IsPromotable (Employee employee); // Declaration Syntax is similar to that of a method's 
      class Program
      {
          public static void Main(string[] args)
          {
               //code goes here
          }
      }
  
      class Employee
      {
          public int EmployeeId { get; set; }
          public string EmployeeName { get; set; }
          public int Salary { get; set; }
          public int Experience { get; set; }
  
          public void PromoteEmployees(List&lt;Employee&gt; employeeList, IsPromotable isPromotableObj)
          {
  
              /*foreach (Employee employee in employeeList)
              {
                  if (employee.Experience &gt;= 5 &amp;&amp; employee.Salary &gt;= 10000) //That's a hard-coded logic that you have developed as a Framework Developer which makes the class itself not reusable
                  {
                      Console.WriteLine(" {0} will be promoted in the next R.P. Cycle ", employee.EmployeeName);
                  }
              }
              Console.ReadKey();*/
  
              foreach (Employee employee in employeeList)
              {
                  if (isPromotableObj(employee)) 
                  {
                      Console.WriteLine(" {0} will be promoted in the next R.P. Cycle ", employee.EmployeeName);
                  }
              }
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>Now the problem I am facing is, I am trying to read from this assembly in my program and trying to invoke the delegate which takes in a class instance as a parameter.
  What I am doing is something like this in a different class altogether</p>
  
  <pre><code>  namespace ReflectionSample
  {
      delegate bool empIsPromotable (Object obj);
      class Program
      {
          static void Main(string[] args)
          {
  
              Console.WriteLine("***************Loading External assembly*************");
              Assembly assembly = Assembly.LoadFrom(@"C:\Users\Chiranjib\Documents\visual studio 2012\Projects\DelegatesSampleApplication\DelegatesSampleApplication\bin\Debug\DelegatesSampleApplication.exe");
              Type employeeType = assembly.GetType("DelegatesSampleApplication.Employee"); //Gets the System.Type object for the Employee Class from the just loaded assembly with all it's dependencies
  
              Console.WriteLine("***************Loading External assembly properties*************");
  
             //Setting properties here
  
              Console.WriteLine("***************Creating an array list that will hold these employee instances***************");
              List&lt;Object&gt; employeeInstanceList = new List&lt;object&gt;();
              employeeInstanceList.Add(employeeInstance);
              employeeInstanceList.Add(employeeInstance2);
  
              Console.WriteLine("***************Invoking External assembly methods*************");
                          var args = new Object[] {
  new List&lt;employeeType&gt;(),
  (((employeeInstance) =&gt; { return true; }))
  </code></pre>
  
  <p>};</p>
  
  <pre><code>            Console.ReadKey();
  
          }
      }
  }
  </code></pre>
  
  <p>This throws error. Saying employeeType missing an assembly reference. Also I cannot convert a lambda expression into an object. I cannot directly type cast to (IsPromotable) right ? I am using reflection. So I am supposed not to have a direct access.</p>
  
  <p>How would I be able to access the delegate via reflection ? 
  Please help me through. Thanks in advance.</p>