.NET Compiler – Compile code at runtime

.NET Compiler – Compile code at runtime

What is .NET Compiler? With the .NET Compiler module you may compile .NET source code (with C# or VB syntax) at runtime, create instance of compiled classes and Execute their functions. You can compile code from files or directly from a string. How does .NET Compiler work?

  1. Compile your source code with or without specific compiler parameters (optionally add references to Microsoft .NET or third party libraries like System.Web.dll or WinSCPnet.dll)
  2. Create an instance to a class (static or non-static doesn’t matter) from the assembly step 1 just created. For creating an instance you need the full namespace where the class is in (e.g. “MVCApplication.Core.Login”) and the actual class name.
  3. Directly execute a method in that instance and pass parameters or get a delegate to that method to call

Integrate .NET Compiler in your project Just add the compiler project to your solution or add the build as a reference. There is also an example project in the solution that is well documented for easy starting. What is included

  • full source code
  • example files
  • example project
  • heavy commented example and library (public methods)


  • 1.0 (2015-05-10)
    • initial release

More items by Freggl

PDF Bookshelf - A responsive MVC bookshelf app .NET Compiler - Compile code at runtime OfficeExporter - SQL or DataTable to xls and mdb X to DataTable - convert Excel, Access, CSV EasyConfig - dynamically create config pages