Vinod Maurya Vinod Maurya - 3 years ago 230
C# Question

execute c# code at runtime from code file

I have a WPF C# application that contains a button.

The code of the button click is written in separate text file which will be placed in the applications runtime directory.

I want to execute that code placed in the text file on the click of the button.

Any idea how to do this?

Answer Source

You can use Microsoft.CSharp.CSharpCodeProvider to compile code on-the-fly. In particular, see CompileAssemblyFromFile.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download