Reputation: 83
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...
Upvotes: 2
Views: 3475
Reputation: 908
I have created an application which will run c# like script without using visual studio. It is on https://sourceforge.net/projects/csharpquickcode/
Upvotes: 0
Reputation: 578
Check out the System.CodeDom namespace.
This article contains lots of useful information: http://www.developerfusion.com/article/4529/using-net-to-make-your-application-scriptable/2/
Upvotes: 1
Reputation: 3829
You can use the Compiler namespace and compilate the code at runtime. Take a look here for an explanation on how to do it.
Upvotes: 0
Reputation: 128317
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.
Upvotes: 5
Reputation: 41236
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.
Upvotes: 2
Reputation: 17146
Are you looking for a test bench sort of?
I use LinqPad for that.
It is mostly a test bench for Linq queries, but I find it very useful for C# statements and mini programs and such.
Upvotes: 1