Ghyath Serhal
Ghyath Serhal

Reputation: 7632

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 to generate a dll.

Upvotes: 1

Views: 1798

Answers (2)

TToni
TToni

Reputation: 9391

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.

Upvotes: 2

alpha-mouse
alpha-mouse

Reputation: 5003

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.

Upvotes: 1

Related Questions