0

Now this has been bugging me for ages and it's time to find out if it's possible. I currently have a working CodeDom that can compile one class, but I have created a program with multiple classes that I want to compile with CodeDom. I've tried looking here: CodeDom - Linking multiple classes within a single Assembly ^ No help... and here: http://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.aspx ^ Not much help...

So, is this possible? And if so, how specifically do I do it? How can I link my classes together and compile?

1 Answer 1

2

At the top of the CodeDOM tree, there is CodeCompileUnit, which is roughly equivalent to a single C# source code file. When you use CompileAssemblyFromDom() to compile, it actually takes a collection of CodeCompileUnits. This means you can easily compile multiple classes at once: just create a separate CodeCompileUnit for each of them.

But that's not the only option, CodeCompileUnit (just like a C# file) can contain multiple class declarations (indirectly through CodeNamespace), so you could use that instead.

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

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.