4

Is there some way to get the source code files from the executable I generated using CodeDom? I would like to be able to open the source files so that I can clearly see where I made errors generating any code.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275

1 Answers1

4

If you generate an executable with CodeDom, you can also generate its source code from it. The example below shows how to create a source file from the CodeCompileUnit object.

CodeDomProvider provider = CodeDomProvider.CreateProvider("C#");
System.CodeDom.Compiler.CodeGeneratorOptions options = new CodeGeneratorOptions();
options.BracingStyle = "C";
using (StreamWriter sw = File.CreateText(@"c:\temp\MyFile.cs"))
{
    provider.GenerateCodeFromCompileUnit(unit, sw, options);
}
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171