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?

Community
  • 1
  • 1
Daaksin
  • 834
  • 3
  • 13
  • 28

1 Answers1

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.

svick
  • 236,525
  • 50
  • 385
  • 514