4

I need to add a class (Type) to the CodeNamespace. I have a C# class already written but I don't want to convert it manually to CodeDOM. Is there a way to load an existing into a CodeTypeDeclaration.

It can be runtime or pre-build process.

jsgoupil
  • 3,788
  • 3
  • 38
  • 53

1 Answers1

0

You can compile code from files using codedom CompileAssemblyFromSource. I added an example which set the class content and compile it like here.

For more information you can explore for usages of CompileAssemblyFromSource.

Oren Haliva
  • 351
  • 3
  • 14
  • That's a good idea but it is not exactly what I want... I want to load a file directly into the CodeTypeDeclaration so it can be output properly when I call codeProvider.GenerateCodeFromNamespace(..) – jsgoupil Feb 23 '15 at 20:29