CodeDomProvider provider = CodeDomProvider.CreateProvider("C#"); CompilerParameters parameters = new CompilerParameters(); parameters.GenerateExecutable = false; parameters.GenerateInMemory = true; parameters.ReferencedAssemblies.Add("System.dll"); parameters.ReferencedAssemblies.Add("System.Web.Services.dll"); parameters.ReferencedAssemblies.Add(PathUtils.ApplicationBasePath + @"\ET.Common.dll"); parameters.ReferencedAssemblies.Add(PathUtils.ApplicationBasePath + @"\ET.Deap.BusinessLogic.Plugins.Interfaces.dll"); // When you need to add more References: add the correct assemblyname HERE CompilerResults results = provider.CompileAssemblyFromSource(parameters, sb.ToString()); // if errors occured in the programming Code out of the database if (results.Errors.HasErrors) { // Do Something } else // no errors occured in the code, proceed with testing the businessRules { Assembly assembly = results.CompiledAssembly; // add to dictionary with codesnippet id as key asmList.Add(cs.Id,assembly); } foreach (KeyValuePair<int, Assembly> kvp in asmList) { // this one is not giving back the type!!!! Type ClassType = kvp.Value.GetType("DynamicAssemblyClass"); MethodInfo methodInfo = ClassType.GetMethod("BusinessRuleMethod"); ValidationResult vr2 = new ValidationResult(true); try { methodInfo.Invoke(null, new object[] { obj, projectId, vr2 }); } catch (Exception ex) { // do something }