0

How to create a program (Parent Program) that creates .cs(generate source code programatically from a Parent Program) file and compile it and execute after successfull compilation and communicate result with Parent program.

What i done is

Step 1: i can create file using c# application using System.IO namespace

Step 2: there is option that we can compile program by command line using "csc" from console can execute it by using Prosess.Start() in System.Globalization namespace

But the Problems are

  1. how to know it's compiled properly.

  2. how to communicate Parent program with generated program

4
  • Please expand on what you mean by "creates .cs files". Commented Mar 26, 2013 at 5:55
  • .cs file means another c# program. why every one is vote it down. does any thing wrong in it? Commented Mar 26, 2013 at 5:57
  • That part was clear. What is unclear is what you mean by "create". Do you want to generate source code programatically? Or does the source code already exist and you just want to compile it? Commented Mar 26, 2013 at 5:59
  • want to generate source code programatically from a Parent Program Commented Mar 26, 2013 at 6:02

1 Answer 1

2

Take a look at System.Reflection.Emit - that allows you to generate MSIL assemblies at runtime. Here are two starting points:

http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx

http://msdn.microsoft.com/en-us/library/3y322t50.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.