Execute .NET code at runtime
Suppose i write 'piece of code' in a text file. Is it possible to read that file at runtime and...execute ? For example, suppose my software have a method1, method2 and method3 methods. In a text file i write any simple piece of code, like:
dim i as integer
i = method1() + method2()
console.write(i)
How can execute it开发者_运维知识库 dinamically, at runtime ?
CodeDOMProvider and the System.CodeDom.Compiler Namespace is where you will want to start. But you will have to write more extensive code than your sample.
There is an example on MSDN for both VB and C#
精彩评论