private void Compile()
        {
            k.RefAssemblies.Clear();

            Assembly s  = Assembly.LoadFile(@"C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll");
            Assembly s1 = Assembly.LoadFile(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll");

            k.RefAssemblies.Add(s);
            k.RefAssemblies.Add(s1);
            var AssembliesList = ManiPulateMainClass.GetAssemblyNames(textBox1.Text);


            foreach (var assembly in AllAssemblyFiles)
            {
                foreach (string CodeAssembly in AssembliesList)
                {
                    if (CodeAssembly != "System")
                    {
                        if (assembly.Contains(CodeAssembly))
                        {
                            k.RefAssemblies.Add(Assembly.LoadFile(assembly));
                        }
                    }
                }
            }

            UpdateList update = new UpdateList(UpdateUI);

            this.Invoke(update, k.RefAssemblies, CompilationClass.Classname(textBox1.Text));


            k.CompilationError += new ErrorEventHandler(k_CompilationError);
            k.CompileCSharp(textBox1.Text, "Sample.exe");
            //button1.Enabled = true;
        }
Ejemplo n.º 2
0
        private void Compile()
        {
            k.RefAssemblies.Clear();

            Assembly s  = Assembly.LoadFile(@"C:\assemblies\mscorlib.dll");
            Assembly s1 = Assembly.LoadFile(@"C:\assemblies\System.Core.dll");

            k.RefAssemblies.Add(s);
            k.RefAssemblies.Add(s1);



            var AssembliesList = ManiPulateMainClass.GetAssemblyNames(t);



            //foreach (var assembly in AllAssemblyFiles)
            //{
            //    foreach (string CodeAssembly in AssembliesList)
            //    {

            //        if (CodeAssembly != "System")
            //        {
            //            if (assembly.Contains(CodeAssembly))
            //            {
            //                k.RefAssemblies.Add(Assembly.LoadFile(assembly));
            //            }
            //        }

            //    }
            //}

            UpdateList update = new UpdateList(UpdateUI);

            this.Invoke(update, k.RefAssemblies, CompilationClass.Classname(t));

            // k.CompilationError += new ErrorEventHandler(k_CompilationError);
            // k.CompileCSharp(t, "Sample.exe");
        }
        public static string Classname(string code)
        {
            string        mainNameSpace = string.Empty;
            List <string> classcode     = new List <string>();
            List <string> classname     = new List <string>();
            List <string> NamespaceCode = new List <string>();
            List <string> nmSpaceName;
            string        mainClass = string.Empty;

            ManiPulateMainClass.ManipulateNameSpace(code, out NamespaceCode, out nmSpaceName);
            for (int x = 0; x < nmSpaceName.Count; x++)
            {
                ManiPulateMainClass.ManipulateClasses(NamespaceCode[x], out classname, out classcode);


                mainClass = ManiPulateMainClass.GetMainClass(classname, classcode);

                mainNameSpace = nmSpaceName[x];
            }
            string[] mainClassName = mainClass.Split(':');
            return(string.Format("{0}.{1}", mainNameSpace.Trim(), mainClassName[0].Trim()));
        }