create c# project at runtime
Does any body know how can I create a C# project at runtime, add classes to it and compile it开发者_JAVA百科 to generate a dll.
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.
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.
精彩评论