public static ISmtpContext CreateSmtpObject(string name) { string className = (string)classMaps[name]; if (className == null) { throw new ArgumentNullException(String.Format("Class not found [{0}]", name)); } Assembly asm = Assembly.GetExecutingAssembly(); ISmtpContext obj = (ISmtpContext)asm.CreateInstance(className); if (loggerFactory != null) { Type t = obj.GetType(); ILogger logger = loggerFactory.CreateLogger(t); obj.SetLogger(logger); } return(obj); }