Run .NET code at runtime

Suppose I write a “piece of code” in a text file. Is it possible to read this file at runtime and execute? For example, suppose my software has methods method1 , method2, and method3 . In a text file, I write any simple piece of code, for example:

dim i as integer i = method1() + method2() console.write(i) 

How to execute it dynamically at runtime?

0
source share
3 answers

CodeDOMProvider and System.CodeDom.Compiler Namespace is where you want to start. But you will have to write more extensive code than your sample.

+2
source

Yes, is it possible to dynamically compile and execute C # code snippets?

Have you tried a quick search? There are many resources for this.

0
source
0
source

Source: https://habr.com/ru/post/905955/


All Articles