2

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...

6 Answers 6

5

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I think only specific parts of the built in C# compiler are deprecated because there are new and better methods.
I check simpleDevelopment source codes but it is not the exact thing that I want. What I mean is there should be keywords as c# and works as c# but this library should give task what to do, so it can be available to add new keywords.script should not be type-safe I mean a c# script similar to javascript
My main point is that , When user define lots of variable , I want to reach them where ever I want, my point is not to only compile the runtime c# code and creating assembly.
2

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.

Comments

1

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.

Comments

1

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/

Comments

0

You can use the Compiler namespace and compilate the code at runtime. Take a look here for an explanation on how to do it.

Comments

0

I have created an application which will run c# like script without using visual studio. It is on https://sourceforge.net/projects/csharpquickcode/

C# Quick Code

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.