CodeDomProvider strange error

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using this code which I copied from MSDN site with only slight modifications.<br/><br/>        private void pushCompile_Click ( object sender, EventArgs e )<br/>        {<br/>            if ( this.txtSourceFilesForCompilation.Text == "" )<br/>            {<br/>                TSP.textToSpeech ( "Source files text box is empty" );<br/>                return;<br/>            }<br/>            CodeDomProvider codeProvider;<br/>            codeProvider = CodeDomProvider.CreateProvider ( "C#" );<br/>            string Output = "Out.dll";<br/>            Button ButtonObject = ( Button )sender;<br/>            this.txtResourceFilesToCompile.Text = "";<br/>            System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters ( );<br/>            switch ( this.pushCompileOptions.Text )<br/>            {<br/>                case "Generate Executable":<br/>                    parameters.GenerateExecutable = true;<br/>                    break;<br/>                case "Generate Dll":<br/>                    parameters.GenerateExecutable = false;<br/>                    break;<br/>            }<br/>            parameters.OutputAssembly = Output;<br/>            CompilerResults results = codeProvider.CompileAssemblyFromSource ( parameters, this.txtSourceFilesForCompilation.Text );
            if ( results.Errors.Count > 0 )<br/>            {<br/>                this.txtResourceFilesToCompile.ForeColor = Color.Red;<br/>                foreach ( CompilerError CompErr in results.Errors )<br/>                {                   <br/>                    this.txtResourceFilesToCompile.Text = this.txtResourceFilesToCompile.Text +<br/>                                "Line number " + CompErr.Line +<br/>                                ", Error Number: " + CompErr.ErrorNumber +<br/>                                ", " + CompErr.ErrorText + ";" +<br/>                                Environment.NewLine + Environment.NewLine;<br/>                }<br/>            }<br/>            else<br/>            {<br/>                //Successful Compile<br/>                this.txtResourceFilesToCompile.ForeColor = Color.Blue;<br/>                this.txtResourceFilesToCompile.Text = "Success!";<br/>                if ( ButtonObject.Text == "Run" ) Process.Start ( Output );<br/>            }<br/>        }                                               // pushCompile_Click<br/><br/><br/>No matter what file I want to compile and I want to compile to a dll I get this error:<br/><br/>Line number 1, Error Number: CS1056, Unexpected character ;<br/><br/>There is no back slash anywhere in my files on line 1.<br/><br/>What is the problem with the code?<br/><br/>Thanks.
<hr class=sig>
AlexB

View the full article
 
Back
Top