Search code examples
compiler-constructioncode-generation.net-assemblycodedom

Compile at run time exclude class that is generated by CodeDom


I have used CodeDom to generate class so called "Product.cs", my class has been generated in right path but my code does not work perfect and complete because of this "Product.cs" is exclude from my solution and I have to include it at run time I searched and found way to create csc.exe and load assembly in order to compile my class at run time and include it in my solution and after that I can work on "Product.cs".

I am writing code by Visual Studio 2013 on web application such as MVC. Thank you in advanced for any helps.


Solution

  • It will work for you. I just tried, see comments

    • if you want to include class files, edit the project file. This file is a xml file. You can easily edit it. To know the tag, I suggest please open the project file in any text editor like notepad, use MSBuild or whatever you want to use to build your project.
    • if you want to generate and create a project see reflection. Also, check this: http://www.codeproject.com/Articles/10324/Compiling-code-during-runtime