1

Does any body know how can I create a C# project at runtime, add classes to it and compile it to generate a dll.

1
  • 1
    Do you need a visual-studio project, or just to compile the code? Commented Nov 29, 2010 at 14:05

2 Answers 2

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.

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

Comments

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.

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.