oclockvn
4/6/2015 - 9:05 AM

dynamicdllmethod2.cs

public object Process(
                         string path, 
                         string assembyName, 
                         string className, 
                         string methodName, 
                         object[] parameters)
        {
            object obj = null;  // return object of method
            MethodInfo methodInfo = null;
            ConstructorInfo constructorInfo = null;
            Type type = null;   // type of assembly
            object responder = null; // kind of instance
            Type[] paramTypes;
            int count = 0;
   
            // ...
   
            try
            {
                if (!File.Exists(path + "\\" + assembyName + ".dll"))
                {
                    using (StreamWriter writer = new StreamWriter(path + "\\assembly_log.txt", true))
                    {
                        writer.WriteLine(DateTime.Now + assembyName + ".dll is not exist.");
                    }
                    return null;
                }
    
                // ...
            }
            catch (Exception ex)
            {
                // logger.Log(DateTime.Now + " : " + ex.Message, path + "\\log_" + assembyName + ".txt");
            }
            finally
            {
                methodInfo = null;
                constructorInfo = null;
                responder = null;
                type = null;
                paramTypes = null;
            }

            return obj;
  }