Does any body know how can I create a C# project at runtime, add classes to it and compile it to generate a dll.
Asked
Active
Viewed 1,687 times
1
-
1Do you need a visual-studio project, or just to compile the code? – Ian Ringrose Nov 29 '10 at 14:05
2 Answers
2
If you just want to compile code and generate a dll, see cdhowie's answer.
If you want to have a complete project file at the end, you can create a csproj file through XML or Text output, which points to the code (and other) files you want to include, then execute "msbuild myproject.csproj".
Open a .csproj file for a project you have with notepad, the structure isn't complicated.

TToni
- 9,145
- 1
- 28
- 42
1
If you are interested in creating dynamic classes for your own use the have a look at System.Reflection.Emit namespace. You can create assembly full of types on the fly.

alpha-mouse
- 4,953
- 24
- 36