Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:40:53+00:00 2026-05-26T04:40:53+00:00

I am trying to build a C# program that converts a different language into

  • 0

I am trying to build a C# program that converts a different language into C# code. I have the program working fine, converting the code and writing it to a .cs file. I want to have this file automatically be compiled, and run, however I cannot figure out how to do this with C#.

I can do it manually by simply running a batch file I wrote, and I attempted to run this batch file from C# using the System.Diagnostics.Process class. When it ran it gave an error within the batch code itself, saying that none of the commands were found (the usual “not an executable, batch file etc”). I can’t figure out why it runs normally, but not when ran from C#.

Here’s the batch file code:
C:\Program_Files_(x86)\Microsoft_Visual_Studio 10.0\VC\bin\amd64\vcvars64.bat
csc %1.cs
pause

and the function that calls it:

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "compiler\\compile.bat";
process.StartInfo.Arguments = " "+fileName;
process.Start();
process.WaitForExit();
process.StartInfo.FileName = fileName + ".exe";
process.Start();
process.WaitForExit();
Console.WriteLine("done");

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:40:53+00:00Added an answer on May 26, 2026 at 4:40 am

    Don’t call the C# compiler or any compiler of .net plataform using a batch script – it’s a bad pratice. You can do this using only C#.
    using the CodeDomProvider class you can write this easily.

      static void CompileCSharp(string code) {
        CodeDomProvider provider = CodeDomProvider.CreateProvider("C#");
        ICodeCompiler compiler = provider.CreateCompiler();
        CompilerParameters parameters = new CompilerParameters();
        parameters.OutputAssembly = @"D:\foo.exe";
        parameters.GenerateExecutable = true;
        CompilerResults results = compiler.CompileAssemblyFromSource(parameters, code);
        if (results.Output.Count == 0)
        {
            Console.WriteLine("success!");
        }
        else
        {
            CompilerErrorCollection CErros = results.Errors;
            foreach (CompilerError err in CErros)
            {
                string msg = string.Format("Erro:{0} on line{1} file name:{2}", err.Line, err.ErrorText, err.FileName);
                Console.WriteLine(msg);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a server program that receives file from client using
I was trying to build a program that puts a radical into simplest radical
I'm trying to build a small program that hosts vst effects and I would
I am trying to build a program that will get all the system keyEvents
I am trying to build a program that uses libusb and I get a
I am trying to build a program that, once the button was click, every
Helllo! I'm trying to build a program that calculates the best score from a
I'm trying to build a really basic program that will alternate between two pictures
I'm trying to build a class that stores program settings as a std::map. Since
i m trying to build an invoice program that holds data in an Access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.