1

Possible Duplicate:
Compile and run dynamic code, without generating EXE?
How to Compile the .cs file into .dll in C#.Net programtically?

In .NET 4.0 i would like to do the following.

  1. Write cs files at runtime.
  2. Compile cs files at runtime.
  3. Create Instances of these files at runtime.

Is it possible and how?

Community
  • 1
  • 1
FuryFart
  • 2,304
  • 4
  • 27
  • 43
  • The files contain classes. So i would like to create instances of classes i wrote at runtime. – FuryFart Sep 28 '12 at 05:31
  • You mean how to write and compile sourcecode, *then link/import the result into an already-running process, and finally instantiate instances of classes in said sourcecode from the running code*? – lc. Sep 28 '12 at 05:35
  • 1
    Interesting idea, but why? Would you mind explaining why/what you would need this for? – Kjartan Sep 28 '12 at 05:45

1 Answers1

3

Yes. It is possible. To create and compile classes, you can use CodeDOM. Then you could create instances use them in your code.

Why are you trying to do this? If you can provide more information, someone can provide better alternative.

danish
  • 5,550
  • 2
  • 25
  • 28