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 6323103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:27:20+00:00 2026-05-24T16:27:20+00:00

I would like to compile c# source code from a string. I know this

  • 0

I would like to compile c# source code from a string. I know this is possible using CodeDom, and I would like to know if it’s possible to do this using the command line compiler. For example, say I load the following code onto a string:

static void Main(string[] args)
        {           

        }

Is there some way to compile this code into a c# executable (.exe) file without first writing this code to my hard drive in the form of a C# class (.cs) file?

That was the first part of my question. The second part assumes that the above is in fact impossible. Let’s say I had three difference classes (loaded onto three separate strings). How would I go about using the Command line compiler to compile each of these three classes into one common executable file? I have found some examples online, but they seem to be very vague, unfortunately.

Any help, or pointers in the right direction is much appreciated.

Thank you,
Evan

  • 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-24T16:27:22+00:00Added an answer on May 24, 2026 at 4:27 pm

    No, you can’t use csc.exe without a source file. What is your rationale for needing to use csc.exe? Have you found something that the CodeDOM doesn’t handle correctly? A command-line option you don’t have a CodeDOM equivalent for?

    The C# team mentioned that a future version might support compiler-as-a-service, where csc.exe would just become a thin wrapper around a compiler DLL, that you could also call directly. But you’d still need to bypass csc.exe.

    You can use System.CodeDom.Compiler.CompilerParameters to get CodeDOM to give you the same results as csc.exe. Check the build log to find out what options Visual Studio is passing to csc.exe. Specifically, the architecture (AnyCPU vs x86) is likely to make a big difference, since it determines whether the resulting assembly will be compatible with 32-bit DLLs when run on Windows x64. Or you can use corflags to fix the architecture after compilation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fine working on Linux using gcc as my C compiler but would like
Suppose I compile a source file file which contains this piece of code, struct
I would like to compile a DLL under Visual Studio 2008 that depends on
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to test a string containing a path to a file for
I would like to sort an array in ascending order using C/C++ . The
I would like to have a reference for the pros and cons of using
I would like to get a sum from a column, with and without a
Currently I am trying to compile native code for Android. The code is from
I want to compile some .java files into a JAR. I would like to

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.