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.
Asked
Active
Viewed 695 times
1 Answers
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