.netvb.netdynamic-compilationvbcodeprovider

How can I compile dynamic code at runtime in the current assembly?


I use VBCodeProvider to compile code, but it generates a new assembly, and also I need to add all references to assemblies I need to use.

Is there a way to compile code in the current assembly?


Solution

  • You cannot temper the current assembly.

    A couple of years ago, I have written an on the topic of dynamic compilation: http://emoreau.com/Entries/Articles/2011/07/Compiling-code-on-the-fly.aspx

    BTW, Roslyn is only available if you are using VS2015 (unless you are using the CTPs that were available for VS2013 but it is not a good idea for anything else then testing).