Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using c# like script in runtime

Tags:

c#

interpreter

I want to learn if there is any library in .net to write c# scripts. Let me describe you with more detail, for example I have an application. When I run it, a c# editor will be opened end user will write some c# codes and when click run, this code should be evaluated and dom should be created after interpret my run time c# code will run. this is brief description of my mind...

like image 662
Burcu Co Avatar asked Jan 29 '26 17:01

Burcu Co


2 Answers

I put together a little app called SimpleDevelop which uses CSharpCodeProvider to do what you describe. My understanding is that this (CodeDom) is deprecated and generally discouraged; however, it seems to work just fine for simple scenarios.

like image 119
Dan Tao Avatar answered Jan 31 '26 05:01

Dan Tao


Basically, you want to use something like the CSharpCodeProvider. The Razor view engine in MVC essentially uses this to compile your code into an executable to run. If you want your user to be able to write code and then have it interpreted, you would start here. Please note though, this is an incredibly complicated and time intensive feat to get right; plus, linking in and executing foreign code dynamically is a security nightmare. Just be safe.

like image 25
Tejs Avatar answered Jan 31 '26 07:01

Tejs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!